Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@extra-array/bubble-sort

nodef57MIT2.9.41TypeScript support: included

Arranges values in an order.

extra, array, bubble, sort, bubbleSort

readme

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

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

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

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

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

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

references