A tiny (110B), fast and simplified array sort
$ npm install --save sort-arr
const sortArr = require('sort-arr')
const arr = [
{ band: 'Lights', members: 1 },
{ band: 'Blink-182', members: 3 },
{ band: 'Jamestown Story', members: 1 }
]
sortArr(arr, 'band')
/* => [
{ band: 'Blink-182', members: 3 },
{ band: 'Jamestown Story', members: 1 },
{ band: 'Lights', members: 1 }
]
*/
Returns an array
Type: array
Array to be sorted
Type: string
Name of the object key
// Fastest is sort-arr
sort-array
--> 35,101 ops/sec ±4.01% (85 runs sampled) | Diff: N/A
array-sort
--> 186,025 ops/sec ±8.78% (70 runs sampled) | Diff: 429.97% faster
sort-arr
--> 1,014,953 ops/sec ±6.87% (76 runs sampled) | Diff: 445.60% faster
MIT © Bu Kinoshita