Arranges values in an order.
npm install @extra-array/sort-update.minArranges values in an order.
:package:
:smiley_cat:
:running:
:vhs:
:moon:
:scroll:
:newspaper:
:blue_book:
> Alternatives: [sort], [sort$].
> Similar: [sort], [merge].
> 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-update].
> It is exported as global variable array_sort$.
> CDN: [unpkg], [jsDelivr].
[@extra-array/sort-update]: https://www.npmjs.com/package/@extra-array/sort-update
[unpkg]: https://unpkg.com/@extra-array/sort-update.min
[jsDelivr]: https://cdn.jsdelivr.net/npm/@extra-array/sort-update.min
``javascript`
array.sort$(x, [fc], [fm]);
// x: an array (updated)
// fc: compare function (a, b)
// fm: map function (v, i, x)
// → x
`javascript
const array = require("extra-array");
var x = [-2, -3, 1, 4];
array.sort$(x);
// [ -3, -2, 1, 4 ] (compares numbers)
x;
// [ -3, -2, 1, 4 ]
var x = [-2, -3, 1, 4];
array.sort$(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ 1, -2, -3, 4 ]
var x = [-2, -3, 1, 4];
array.sort$(x, null, v => Math.abs(v));
// [ 1, -2, -3, 4 ]
``
- Data.Sort.sortBy: Haskell
- Array.prototype.sort: MDN web docs
- Array.sortBy: sugarjs
[sort]: https://github.com/nodef/extra-array/wiki/sort
[sort$]: https://github.com/nodef/extra-array/wiki/sort$
[merge]: https://github.com/nodef/extra-array/wiki/merge