Sort an array on two object properties
$ npm install --save double-sort
const doubleSort = require('double-sort');
// sort by two object properties
doubleSort([{pending: 1, type: 'DEL'}, {pending: 2, type: 'HOLD'}, {pending: 3, type: 'DEL'}, ...], 'type', 'pending');
//=> [{pending: 3, type: 'DEL'}, {pending: 1, type: 'DEL'}, {pending: 2, type: 'HOLD'}, ...]
Returns a new sorted array.
Type: Array
Type: string
First parameter to be sorted on.
Type: string
Second parameter to be sorted on. (property1 will always be respected first.)
MIT © Jack Hanford