@philskat/js-sort
v1.2.0
Published
Package with a few sorting algorithms
Downloads
3
Readme
js-sort
This npm package contains a few sorting algorithms to sort arrays of numbers.
Quick Sort
const { quickSort } = require('@philskat/js-sort');
const arr = quickSort([3, 1, 2]); // Output: [1, 2, 3]
Bubble Sort
const { bubbleSort } = require('@philskat/js-sort');
const arr = bubbleSort([3, 1, 2]); // Output: [1, 2, 3]
Insertion Sort
const { insertionSort } = require('@philskat/js-sort');
const arr = insertionSort([3, 1, 2]); // Output: [1, 2, 3]
Insert Sorted
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]