UNPKG

ng2-stable-nxtc

Version:

Angular Smart Table neXtCode Version

19 lines 550 B
export class LocalSorter { static sort(data, field, direction, customCompare) { const dir = (direction === 'asc') ? 1 : -1; const compare = customCompare ? customCompare : this.COMPARE; return data.sort((a, b) => { return compare.call(null, dir, a[field], b[field]); }); } } LocalSorter.COMPARE = (direction, a, b) => { if (a < b) { return -1 * direction; } if (a > b) { return direction; } return 0; }; //# sourceMappingURL=local.sorter.js.map