I\'m using the jQuery tablesorter plugin and I have a column that contains name of month and year like this
April, 1975
January, 2001
I would l
It's a bit of a hack (OK, it's a total hack), but if you set the parser for the column to 'text', and pre-fix your pretty output with the string you really want to sort on within a hidden span it will sort correctly.
You can set the parser on a column with the headers
option, e.g. to set the parser on the first and second columns to 'text' you would set the following:
headers: {0: {sorter: 'text'}, : {sorter: 'text'}
To do this trick with dates, you can use the ISO8601 date format which sorts lexically. JS's Date
objects can generate ISO8601 date strings via the toISOString()
function.
Given the CSS:
span.hidden{
display:none;
}
A sample cell in the table would look like this:
2015-04-18T23:48:3319 April 2015
Not the prettiest code in the world, but it does work.