Search code examples
javascriptjquerytablesorter

jquery Tablesorter - natural sort order?


I've looked through all the answers listed for tablesorter but can't find what I'm looking for.

I have a table which I'm trying to sort, one column contains product model numbers which include both letters and numbers, the problem is that it sorts alphabetically but not with the numbers in their proper order. For example the sorted column comes out like this:

STRB 18, STRB 19, STRB 2, STRB 20, STRB 23 - you get the idea.

I've gathered that I need this column to sort in natural order, but I've not got any js chops to do this with. If anybody could point me in the right direction I would be very grateful!


Solution

  • The jquery tablesorter plugin offers the ability to write your own parser.

    Check out the example and give it a shot!

    http://tablesorter.com/docs/example-parsers.html