Package Exports
- countingsort
- countingsort/dist/index.esm.js
- countingsort/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (countingsort) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Javascript/Typescript implementation of Counting sort
Sort an array of integers using Counting sort
Counting sort is the fastest sorting algorithm when the following criteria are met:
- You only have integers
- You know the minimum and the maximum value contained in the array
Note: Not only is it better to sort an integer array using Counting sort, it will actually not work if you try to sort anything else (like floats), so if things don't work, that's where you should be looking
Install using npm
npm install contingsort
# or
yarn add countingsortUsage:
import { countingSort } from 'countingSort'
const myArray = [5, 3, 2, 0, 6, 4, 3, 6, 10, 0, 3, 2]
countingSort(myArray, 0, 10) // should sort the array to [0,0,2,2,3,3,3,4,5,6,6,10]
// Note: this algorithm actually modifies the input arrayMisc
License
MIT