sort-ts
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

sort-ts

build

Sorting algorithms for Typescript. All of the implemented algorithms are at the moment not-in-place ones, meaning they create and return a new array instead of mutating the original one.

Install

npm install sort-ts

Use

import {
  binaryTreeSort,
  bubbleSort,
  insertionSort,
  mergeSort,
  quickSort,
  selectionSort,
  shellSort
} from 'sort-ts';

// Compare function for ascending order
function compare(a: number, b: number): number {
  return a - b;
}

const orderedArray = bubbleSort([-1, 1, -100, 1000, 23, 34, 10000, 0], compare);
// Same for other algorithms

Contribute

Some algorithms could be added to the library. Feel free to add new ones and create a pull request!

Readme

Keywords

none

Package Sidebar

Install

npm i sort-ts

Weekly Downloads

6

Version

0.0.7

License

GPL-3.0-or-later

Unpacked Size

51.3 kB

Total Files

39

Last publish

Collaborators

  • notsag-dev