0.0.0 • Published 6 years ago
multikeysort v0.0.0
multiKeySort.js
Sort an array using multiple keys in JavaScript
Install
$ npm install multikeysort
Usage
const multiKeySort = require('multiKeySort');
// Sorting numeric values
// Unfortunately can't use arrow functions. Use below method
const sortByX = function (a, b) { return b.x - a.x; };
const sortByY = function (a, b) { return b.y - a.y; };
arr.sort(multiKeySort([sortByX, sortByY]));
Related
thenBy.js - More features with alternative syntax
License
MIT © Phil Cummins
0.0.0
6 years ago