@extra-array/sort-on
TypeScript icon, indicating that this package has built-in type declarations

2.7.8 • Public • Published

Arranges values in an order. 🏃 📼 📦 🌔

Alternatives: compare, compare-update, map, map-update.
This is part of package extra-array.

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

Package Sidebar

Install

npm i @extra-array/sort-on

Weekly Downloads

4

Version

2.7.8

License

MIT

Unpacked Size

9.34 kB

Total Files

24

Last publish

Collaborators

  • wolfram77