tablesorter customer parser not working properly

tablesorter customer parser not working properly

Hi

Tablesorter was working fine until I tried to add in a custom parser as per the help page.

Now what happens is that you can't sort any column ONCE - after this everything freezes. (So if you click the same column again you don't get the opposite sort like you should )

I am something of a newbie so i wasn't sure where to put this code... so I put it at the end of my jQuery file.

Can anyone help please?

  1. $.tablesorter.addParser({
            // set a unique id
            id: 'mlevels',
            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(/m1c/,0).replace(/m1b/,1).replace(/m1a/,2).replace(/m2c/,3).replace(/m2b/,4).replace(/m2a/,5).replace(/m3c/,6).replace(/m3b/,7).replace(/m3a/,8).replace(/m4c/,9).replace(/m4b/,10).replace(/m4a/,11).replace(/m5c/,12).replace(/m5b/,13).replace(/m5a/,14).replace(/m6c/,15).replace(/m6b/,16).replace(/m6a/,17).replace(/m7c/,18).replace(/m7b/,19).replace(/m7a/,20).replace(/m8c/,21).replace(/m8b/,22).replace(/m8a/,23).replace(/m9c/,24).replace(/m9b/,25).replace(/m9a/,26).replace(/m10c/,27).replace(/m10b/,28).replace(/m10a/,29).replace(/m11c/,30).replace(/m11b/,31).replace(/m11a/,32).replace(/m12c/,33).replace(/m12b/,34).replace(/m12a/,35).replace(/m13c/,36).replace(/m13b/,37).replace(/m13a/,38).replace(/m14c/,39).replace(/m14b/,40).replace(/m14a/,41).replace(/m15c/,42).replace(/m15b/,43).replace(/m15a/,44).replace(/-1/,-1);
                   
            },
            // set type, eiahe2 numeric or text
            type: 'numeric'
        });
        
        $(function() {
            $("table").tablesorter({
                headers: {
                    4: {
                        sorter:'mlevels'
                    }
                }
            });
        });