Skip to content

Conversation

@chrisatomix
Copy link

This plugin helped me a lot (thanks!), however I noticed most of the code was being repeated so I spent 15 minutes trying to simplify it. It seems to be working correctly, currency sorting works fine & fast on a table with 500 rows (built using a JS array).
Reduced from 47 lines to 32 lines.

You could probably even reduce it further like so:

$.extend( $.fn.dataTableExt.oSort, {
    "currency-asc" : function (a, b) {
        'use strict';
        return cleanCurrency(a) - cleanCurrency(b);
    },
    "currency-desc" : function (a, b) {
        'use strict';
        return cleanCurrency(b) - cleanCurrency(a);
    }
});

This gets it down to 28 lines, but it's fairly trivial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant