JQuery TinySort not sorting numbers correctly

I have a multiple html tables on a page which each have a header row. When I click that column header it should sort all tables by that column. The column that I am specifically referring to contains an anchor which for text displays a integer value.

When I click the column header I am experience an incorrect sort. Assume I have the following on this screen load:

83
84
104

Now I click the column header the end result becomes:

104
83
84

I have the code written to alternate the sort on the next click and what happens is that the 104 and 84 pivot around the 83. What I believe is happening is that it is comparing these incorrectly. I have tested it with larger data sets and the problem comes up when any of the numbers do not share a common number of digits.

Is there anything (maybe a flag I’m missing?) to tell this thing to sort it correctly? All of my more string-like data sorts correctly.

Code:

var aAsc = [];
$  (".SubHead").click(
    function() {
        var nr = $  (this).index();
        aAsc[nr] = aAsc[nr]=='asc'?'desc':'asc';
        $  ('.resultTable>tbody>tr:not(.SubHeadRow)').tsort("td:eq("+nr+")",{order:aAsc[nr]});
    }
);

newest questions tagged jquery – Stack Overflow

About Admin