The only modification that comes to mind at first might be to use global variables instead of fields to keep track of your sort order data.
Are you using FileMaker 12? There's a new sort script step that may have some utility for you here.
You could use an unique script fired by the OnObjectEnter trigger attached to each single field used as pseudo-buttons in the header part of those layouts.
Try:Set Variable [ $$sort ; Value: not $$sort ]If [ $$sort ]Sort Records by Field [ Ascending ]ElseSort Records by Field [ Descending ]End IfCommit Records/Requests [ ]
Yep, what I had in mind IF you have FIleMaker 12...