@extra-array/selection-sort
Version:
Arranges values in an order.
66 lines (56 loc) • 3.24 kB
Markdown
Arranges values in an order. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:]
> Alternatives: [sort], [sort$].<br>
> Similar: [sort], [merge].<br>
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
```javascript
array.selectionSort(x, [fc], [fm]);
// x: an array
// fc: compare function (a, b)
// fm: map function (v, i, x)
```
```javascript
const array = require('extra-array');
var x = [-2, -3, 1, 4];
array.selectionSort(x);
// [ -3, -2, 1, 4 ] (compares numbers)
array.selectionSort(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ 1, -2, -3, 4 ]
array.selectionSort(x, null, v => Math.abs(v));
// [ 1, -2, -3, 4 ]
```
### references
- [Data.Sort.sortBy: Haskell](https://hackage.haskell.org/package/sort-1.0.0.0/docs/Data-Sort.html#v:sortBy)
- [Array.prototype.sort: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
- [Bubble Sort: Wikipedia](https://en.wikipedia.org/wiki/Bubble_sort)
- [bubble-sort: @tristanls](https://www.npmjs.com/package/bubble-sort)
- [algo-sort-bubble: @bredele](https://www.npmjs.com/package/algo-sort-bubble)
- [bubblesort: @addyosmani](https://www.npmjs.com/package/bubblesort)
- [sort-bubble: @lukebro](https://www.npmjs.com/package/sort-bubble)
- [bubble-sort-js: @JacopoDaeli](https://www.npmjs.com/package/bubble-sort-js)
- [bubble-srt: @abranhe](https://www.npmjs.com/package/bubble-srt)
- [b-sort: alkuhar](https://www.npmjs.com/package/b-sort)
- [@clarketm/superbubblesort: @clarketm](https://www.npmjs.com/package/@clarketm/superbubblesort)
- [sort-algorithms-js: @eyas-ranjous](https://www.npmjs.com/package/sort-algorithms-js)
- [sort-types: @dalalayan1](https://www.npmjs.com/package/sort-types)
- [sorting-helpers: @AntoniAngga](https://www.npmjs.com/package/sorting-helpers)
- [sorti: @nadavgld](https://www.npmjs.com/package/sorti)
- [sortie: @mustafar](https://www.npmjs.com/package/sortie)
- [sorting: @lakhaNamdhari](https://www.npmjs.com/package/sorting)
- [plentiful: @ajnauleau](https://www.npmjs.com/package/plentiful)
- [sort-all-in-one: @OnlyRefat](https://www.npmjs.com/package/sort-all-in-one)
- [sort-algorithms: @sombrerolgringo](https://www.npmjs.com/package/sort-algorithms)
- [sorting-algorithms: @luongnv89](https://www.npmjs.com/package/sorting-algorithms)
- [js-sorting: @jasonheecs](https://www.npmjs.com/package/@jasonheecs/js-sorting)
- [js-sorting-algo: @kumar-gaurav-mishra](https://www.npmjs.com/package/js-sorting-algo)
- [@ds-javascript/sort: @opensourcedj217](https://www.npmjs.com/package/@ds-javascript/sort)
- [sorting-algorithms-rajan: @rajanmidun](https://www.npmjs.com/package/sorting-algorithms-rajan)
- [best-sort: @agniswarm](https://www.npmjs.com/package/best-sort)
[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
[:running:]: https://npm.runkit.com/@extra-array/selection-sort
[:package:]: https://www.npmjs.com/package/@extra-array/selection-sort
[:moon:]: https://www.npmjs.com/package/@extra-array/selection-sort.min
[:ledger:]: https://unpkg.com/@extra-array/selection-sort/
[:vhs:]: https://asciinema.org/a/334741