@extra-array/sort-on.min

Arranges values in an order.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-array/sort-on.min
1622.7.83 years ago3 years agoMinified + gzip package size for @extra-array/sort-on.min in KB

Readme

Arranges values in an order. :running: :vhs: :package: :moon:
Alternatives: compare, compare-update, map, map-update.
This is part of package extra-array.

This is browserified, minified version of @extra-array/sort-on.
It is exported as global variable arraysortOn.
CDN: unpkg
, jsDelivr.

array.sortOn(x, [fn], [ths]);
// x:   an array
// fn:  map function (v, i, x)
// ths: this argument

const array = require('extra-array');

var x = [-3, -2, 1, 4];
array.sortOn(x, v => Math.abs(v));
// [ 1, -2, -3, 4 ]

var x = ['B', 'D', 'a', 'c'];
array.sortOn(x, v => v.toLowerCase());
// [ 'a', 'B', 'c', 'D' ]

references