tochoromero / aurelia-table

Simple functional data table for Aurelia
https://tochoromero.github.com/aurelia-table
MIT License
67 stars 25 forks source link

Add key string to custom Sort parameters for reuse of sorting function #65

Open MishiRover opened 6 years ago

MishiRover commented 6 years ago

Would it be possible to add a key definition to the custom sort parameters so that we are able to reuse the sort function for multiple columns? This would be useful for 2+ date columns, for example.

dateSort(a, b, sortOrder, key) {
        let date1 = new Date(a[key]);
        let date2 = new Date(b[key]);

        if (date1 === date2) {
            return 0;
        }

        if (date1 > date2) {
            return 1 * sortOrder;
        }

        return -1 * sortOrder;
}