# Comparison of all sorting algorithms | Algorithm | Complexity | When to use? | |----------------------------|-----------------------------------------------------|--------------| | 3-way-string-quicksort.js | O(N^2) | | | bubblesort.js | O(N^2) | | | bucketsort.js | O(N) | | | countingsort.js | O(N) | | | heapsort.js | O(N log N) | | | insertion-binary-sort.js | O(N^2) | | | insertionsort.js | O(N^2) | | | lsd.js | O(N*M) for N keys which have M or fewer digits | | | mergesort.js | O(n log(n)) | | | msd.js | O(N*M) for N keys which have M or fewer digits | | | oddeven-sort.js | O(N^2) | | | quicksort-middle.js | O(N log(N)) | | | quicksort.js | O(nlog n) | | | radixsort.js | O(N K) for N keys with K being | | | recursive-insertionsort.js | O(N^2) | | | selectionsort.js | O(N^2) | | | shellsort.js | O((nlog(n))^2) | |