struggling with custom parser on table sorter, any ideas?
Hi Folks,
I'm having a few issues with my custom parser on table sorter. I want to be able to sort currency on our site but it comes in a variety of different formats. dollars, pounds and euros are all displayed in the usual format ($, £, €) however other currencies can be displayed by their 3 letter format such as (HKD, CZK, DKK etc).
I basically want to be able to sort the prices regardless of what comes before it and wondered if anyone knew what I need to add to my custom parser to acheive this:
- ts.addParser({
- id: "newCurrency",
- is: function(s) {
- return /^[£$€€?.]/.test(s);
- },
- format: function(s) {
- return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""));
- },
- type: "numeric"
- });
Thanks in advance