0.0.0 • Published 6 years ago

multikeysort v0.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

multiKeySort.js Build Status Coverage Status

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