I am trying to sort the data in the table using tablesorting plugin but the data has commas(,) as the separator so it is not sorting properly. I think it is considering the number as a string. With the help of google, I have found some codes but those are not working for me. Here is what I have tried so far.
$(document).ready(function(){
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"
});
$("#myTable").tablesorter({
widgets : ['zebra']
});
});
Please tell me what I am doing wrong.
I have given class <th width="62" class="{sorter: 'fancyNumber'}">column</th>
to the column also.