I am using tablesorter plugin to sort my tables in an MVC .NET App. Most of my columns are strings and I\'m having no problems with them. Neither with the numeric ones. The thin
I got the same problem, and I added a custom parser called datetime:
$.tablesorter.addParser({
id: "datetime",
is: function(s) {
return false;
},
format: function(s,table) {
s = s.replace(/\-/g,"/");
s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1");
return $.tablesorter.formatFloat(new Date(s).getTime());
},
type: "numeric"
});
Then you just need to apply that format to the columns you want, as Gabe G exposed (For example to assign this sorter to the first column you should do the following:
$("#mytable").tablesorter(
{ dateFormat: 'dd/mm/yyyy',
headers:
{
0:{sorter:'datetime'}
}
} );