[jQuery] Tablesorter, problems ordering numbers
Hello,
I have a tablesorter with a numeric column (the type is String so I have to use a parser to order the column as number ), the problem is that it does not order long numbers with comas separator.
Here is the example of the sorted column:
desc order--> -363,122,000.00;
-28,000.00;
3,364,000.00;
10,000.00;
68,000.00
asc order--> 68,000.00;
10,000.00;
3,364,000.00;
-28,000.00;
-363,122,000.00
And this is part of my code:
$.tablesorter.addParser({
id: "digit2",
is: function(s,table) {
var c = table.config;
return $.tablesorter.isDigit(s,c);
},
format: function(s) {
alert(s);
if (s.match(',')) {
s = s.replace(/\,/, '');
}
if (s.match('<')) {
s = s.replace(/\</, '');
}
if (s.match(' ')) {
s = s.replace(/\ /, '');
}
return $.tablesorter.formatFloat(s);
},
type: "numeric"
})
$("#credits").tablesorter({headers:
{0:{sorter:'text'}, 1:{sorter:'text'}, 2:{sorter:'text'},
3:{sorter:'digit2'}, 4:{sorter:'digit2'}, 5:{sorter:'digit2'},
6:{sorter: 'dateYYYY/MM/DD'}, 7: {sorter:'digit2'}}});
Can anybody help me with this??
Thanks a lot!!
Sole