Skip to content

This repository contains a node package with various sorting algorithms.

License

Notifications You must be signed in to change notification settings

philskat/js-sort

Repository files navigation

Node.js CI npm bundle size npm Gitpod ready-to-code Docs

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]