I've a problem with a sorting JS plugin for my tables. It's named "Sortable". When you checkout the documentation of this plugin you can find out that you can define your custom sorting types:
https://github.hubspot.com/sortable/api/options/
So I've defined my custom filter and named it price:
sortable.setupTypes([{
name: "numeric", defaultSortDirection: "descending", match: function (a) {
return a.match(d)
}, comparator: function (a) {
return parseFloat(a.replace(/[^0-9.-]/g, ""), 10) || 0
}
}]);
It works particular great but when I add a refund price it works not correctly:
My normal price: 2.372,11 €
My refund price: 765,38 €0,00 €
When the function extracts the refund price, the outcome looks like this: 765,38 € 0,00 € but I must look like this 000.
So I've setup my regex this way /[^0-9-]/g but it's not filtering the del price. Logically the regex needs to get modified the way that it starts after the first €_ or something like this.
Is this possible? If yes, how?