Hi Jay, There was a small bug in the parser.
This works as expected: $.tablesorter.addParser({ // set a unique id id: 'dates', is: function(s) { // return false so this parser is not auto detected return false; }, format: function(s) { // split var a = s.split('-'); // get month num a[1] = this.getMonth(a[1]); // glue and return a new date return new Date(a.reverse().join("/")).getTime(); }, getMonth: function(s) { var m = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'] var l = m.length; for(var i=0; i < l; i++) { if(m[i] == s.toLowerCase()) { return (i+1); } } }, // set type, either numeric or text type: 'numeric' }); /Christian 2007/12/19, Jay Fallon <[EMAIL PROTECTED]>: > > > Hi Christian, thanks for the follow up, > > I implemented the script as you described and it's still not sorting > correctly: > > http://jayfallon.net/tablesorter/tablesorter.html > > On Dec 19, 1:21 pm, "Christian Bach" <[EMAIL PROTECTED]> > wrote: > > Hi Jay, > > > > This will solve your problem: > > > > // add parser through the tablesorter addParser method > > $.tablesorter.addParser({ > > // set a unique id > > id: 'dates', > > is: function(s) { > > // return false so this parser is not auto detected > > return false; > > }, > > format: function(s) { > > // split > > var a = s.split('-'); > > // get month num > > a[1] = this.getMonth(a[1]); > > // glue and return a new date > > return new Date(a.join("/")).getTime(); > > }, > > getMonth: function(s) { > > var m = > > > ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'] > > var l = m.length; > > for(var i=0; i < l; i++) { > > if(m[i] == s.toLowerCase()) { > > return (i+1); > > } > > } > > }, > > // set type, either numeric or text > > type: 'numeric' > > > > }); > > > > /christian > > > > 2007/12/18, Jay Fallon <[EMAIL PROTECTED]>: > > > > > > > > > It's easy to write a parser to convert the months to a sortable value, > > > but the days and years are trickier. the current code is as follows: > > > > > // add parser through the tablesorter addParser method > > > $.tablesorter.addParser({ > > > // set a unique id > > > id: 'dates', > > > is: function(s) { > > > // return false so this parser is not > auto > > > detected > > > return false; > > > }, > > > format: function(s) { > > > // format your data for normalization > > > return s.toLowerCase > > > ().replace(/dec/,12).replace(/nov/, > > > 11).replace(/oct/,10).replace(/sep/,09).replace(/aug/,08).replace(/ > > > jul/,07).replace(/jun/,06).replace(/may/,05).replace(/apr/, > > > 04).replace(/mar/,03).replace(/feb/,02).replace(/jan/,01); > > > }, > > > // set type, either numeric or text > > > type: 'numeric' > > > }); > > > > > $(function() { > > > $.tablesorter.defaults.widgets = ['zebra']; > > > $("#announcements").tablesorter({ > > > headers: { > > > 0: {sorter:'dates'},1: > > > {sorter:false},2: {sorter:false},3: > > > {sorter:false} > > > } > > > }); > > > }); > > > > > On Dec 18, 2:06 pm, Jay Fallon <[EMAIL PROTECTED]> wrote: > > > > I need to sort a table based on the date format: 10-Dec-2007. Does > > > > anyone know if this is possible with Tablesorter? > > > > > > I've tried us, uk & iso to no avail. > > > > > > Thanks, Jay >