Search code examples
javascriptjquerytablesorter

tablesorter does not sort currency as I want


I am currently using the tablesorter jquery plugin created by Christian Bach. It works great, however I have one little problem. In my table I have a column with that contains a currency as data. This currency is in euro. The problem is that the plugin sorts my values wrong. For example tabelsort sorts de values in this order €33,00 €2,00 €1.000,99 while it should be €1.000,99 €33,00 €2,00

So the comma and dot should be ordered differently. Does someone know how I can fix this?

https://github.com/christianbach/tablesorter


Solution

  • I solved my problem with the following code:

    $("table").tablesorter({ textExtraction: function(node){ 
        return $(node).text().replace(/[.$£€]/g,'').replace(/,/g,'.');} 
    });