This npm package contains a few sorting algorithms to sort arrays of numbers.
const { quickSort } = require('@philskat/js-sort');
const arr = quickSort([3, 1, 2]); // Output: [1, 2, 3]
const { bubbleSort } = require('@philskat/js-sort');
const arr = bubbleSort([3, 1, 2]); // Output: [1, 2, 3]
const { insertionSort } = require('@philskat/js-sort');
const arr = insertionSort([3, 1, 2]); // Output: [1, 2, 3]
Add a new entry to an array and sort that entry in the array.
const { insertSorted } = require('@philskat/js-sort');
const arr = [1, 2, 4, 5];
arr = insertSorted(arr, 3); // Output: [1, 2, 3, 4, 5]