Arranges values in an order.
npm install @extra-array/sort-on.minArranges values in an order. [:running:] [:vhs:] [:package:] [:moon:]
> Alternatives: [compare], [compare-update], [map], [map-update].
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
> This is browserified, minified version of [@extra-array/sort-on].
> It is exported as global variable array_sortOn.
> CDN: [unpkg], [jsDelivr].
[@extra-array/sort-on]: https://www.npmjs.com/package/@extra-array/sort-on
[unpkg]: https://unpkg.com/@extra-array/sort-on.min
[jsDelivr]: https://cdn.jsdelivr.net/npm/@extra-array/sort-on.min
``javascript`
array.sortOn(x, [fn], [ths]);
// x: an array
// fn: map function (v, i, x)
// ths: this argument
`javascript
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' ]
``
- Data.Sort.sortOn: Haskell
- Array.prototype.sort: MDN web docs
[compare]: https://github.com/nodef/extra-array/wiki/sort
[compare-update]: https://github.com/nodef/extra-array/wiki/sort$
[map]: https://github.com/nodef/extra-array/wiki/sortOn
[map-update]: https://github.com/nodef/extra-array/wiki/sortOn$
[:running:]: https://npm.runkit.com/@extra-array/sort-on
[:package:]: https://www.npmjs.com/package/@extra-array/sort-on
[:moon:]: https://www.npmjs.com/package/@extra-array/sort-on.min
[:vhs:]: https://asciinema.org/a/319430