jQuery tablesorter sorting comma separated numbers
jquery, tablesorter
Solution
http://www.christianmontoya.com/2008/11/14/extending-jquery-tablesorter-to-support-comma-delimited-numbers/
jQuery.tablesorter.addParser({
id: "fancyNumber",
is: function(s) {
return /^[0-9]?[0-9,\.]*$/.test(s);
},
format: function(s) {
return jQuery.tablesorter.formatFloat( s.replace(/,/g,'') );
},
type: "numeric"
});
Problem
I'm using the jQuery Tablesorter 2.0 (http://tablesorter.com/docs/). Sorting numbers is working fine, but as soon as I add ``` number_format($count); ``` to my code, the sorting is not working anymore. It sorts like this: 810,208 -> 7,671,897 -> 2,329,439 instead of 7,671,897 -> 2,329,439 -> 810,208 Any way to fix this? I need the comma separated number for better reading. Thanks