Search code examples
jquerytablesorter

Initial column sort function not working as expected


I'm trying to sort the 5th column on page load without clicking anything. I can sort the table by clicking the headers but adding this option isn't working for me. I have v2.23.2.

The column I want to sort has numbers, and I want the largest number to be at the top, so descending sort.

$("#table").tablesorter({
    sortInitialOrder: "desc",
    sortList: [4,0]
}); 

Right now, it is sorting with ascension on page load, but that's the default setting and I don't know why it's not working.

Thanks in advance Mottie :$


Solution

  • sortList: [4,1]
    

    A sort value of 0 specifies ascending. You want 1 for descending.

    An array of instructions for per-column sorting and direction in the format: [[columnIndex, sortDirection], ... ] where columnIndex is a zero-based index for your columns left-to-right and sortDirection is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: [[0,0],[1,0]]

    http://mottie.github.io/tablesorter/docs/#api