How to sort date of mm / yy format using jquery tablesorter?
I have a table in which one of the columns displays the date in mm / yy format, viz. 12/08, 01/09, 02/08, etc.
How do I sort on this column using jQuery tablesorter ( http://tablesorter.com ) so that the dates are sorted appropriately?
Using the default date format does not work as it expects a three-element date (mm / dd / yy, for example 01/06/09).
0
source to share
1 answer
See http://tablesorter.com/docs/example-parsers.html for information on custom parsers.
You need to sort the text, but with the year and month included. You can use a format function like this:
format: function(s) {
date = s.split(/\//);
return date[1] + date[0];
},
There may be an easier way, but this is what I was able to find in my quick search through the documentation.
+1
source to share