@extra-array/selection-sort-update

Arranges values in an order. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:] > Similar: [sort], [merge]. > This is part of package extra-array.

Usage no npm install needed!

<script type="module">
  import extraArraySelectionSortUpdate from 'https://cdn.skypack.dev/@extra-array/selection-sort-update';
</script>

README

Arranges values in an order. :running: :vhs: :package: :moon: :ledger:

Similar: sort, merge.
This is part of package extra-array.

array.selectionSort$(x, [fc], [fm]);
// x:  an array (updated)
// fc: compare function (a, b)
// fm: map function (v, i, x)
// --> x
const array = require('extra-array');

var x = [-2, -3, 1, 4];
array.selectionSort$(x);
// [ -3, -2, 1, 4 ] (compares numbers)

x;
// [ -3, -2, 1, 4 ]

var x = [-2, -3, 1, 4];
array.selectionSort$(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ 1, -2, -3, 4 ]

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

references