Better way to sort on a layout in list view
I have a number of layouts in my database that are displayed as lists. The data for each layout is drawn from multiple related tables.
In the header of each layout I have created text headings for each column of fields. Each of these column headings are buttons that run a script that will sort the relevant tables (therefore the column) alternating ascending or descending depenaing on a value in a 'sort' field. The sort field holds a value that determines the last sort , whether ascending or descending, and therefore what the next sort will be when the script is ran again.
Each column heading has a seperate script. Each tables has one 'sort' field.
This method is invloved and heavy depednatn on the use of scripts, especially considering I have four layouts that are viewed as ists, each with around 10 columns of fields.
Is there a better, simpler and more efficent way?