I have an HTML table, tablesorter works fine on it, I am able to set the default sorting and everything else (even my own parser)… BUT: I need some of the columns to be sorted in descending order after the user first clicks on their respective headers.
By default, all the columns are being sorted in ascending order after the first click. I found a way to change this to descending order for ALL the columns. But what I need is to sort some of the columns in ascending order and some other columns in descending order after the user first clicks on them.
Example: Some columns contain strings, so I want to sort them in ascending order. Some columns contain values where bigger values are better – and it would be nice to sort them in descending order after the user first clicks on their headers.
Thank you.
The original tablesorter (version 2.0.5) doesn’t seem to work with this code:
But in my fork of tablesorter, you can use the above code to set the initial sort order for each column – see this demo.
There is also an option named
sortRestartwhich resets the sort order when when the column was previously unsorted – see this demo.