algojs-sorting
Best sorting algorithms on Javascript arrays.
API docs
API docs published here.
var algojs = ; var arr = 8824332129;algojs; // --> arr is sorted!
Algorithms
in place? | stable | worse | average | best | |
---|---|---|---|---|---|
selectionSort | x | N^2 / 2 | N^2 / 2 | N^2 / 2 | |
insertionSort | x | x | N^2 / 2 | N^2 / 4 | N |
shellSort | x | ? | ? | N | |
mergeSort | x | N * logN | N * logN | N * logN |
Selection Sort
Array is sorted as side effect in average quadratic time. See selection sort.
algojs;
Insertion Sort
Array is sorted as side effect in average quadratic time (but linear in best case). See insertion sort.
algojs;
Shell Sort
Array is sorted as side effect in unknown average time (but linear in best case). See shell sort
algojs;
Merge Sort
Array is sorted as side effect in linearithmic time. See merge sort
algojs;