Sorting · Dashboard

Compare every algorithm

Click any column to sort. Click a row to open the algorithm.

AlgorithmBestAverage ↑WorstMemoryStableRecursiveCache friendlyAdaptiveTypical usage
Counting SortO(n + k)O(n + k)O(n + k)O(n + k)yes—yes—Small integer keys; radix building block
Bucket SortO(n + k)O(n + k)O(n²)O(n + k)yes———Uniformly distributed floats
Merge SortO(n log n)O(n log n)O(n log n)O(n)yesyes——External sorting; linked lists; stable sorts
Quick SortO(n log n)O(n log n)O(n²)O(log n)—yesyes—General-purpose in-memory sorting
Heap SortO(n log n)O(n log n)O(n log n)O(1)————Worst-case guarantees; constant memory
Tim SortO(n)O(n log n)O(n log n)O(n)yes—yesyesStdlib default (Python, Java, V8)
Bubble SortO(n)O(n²)O(n²)O(1)yes—yesyesTeaching; detecting already-sorted data
Selection SortO(n²)O(n²)O(n²)O(1)——yes—Minimizing writes (EEPROM/flash)
Insertion SortO(n)O(n²)O(n²)O(1)yes—yesyesSmall or nearly-sorted arrays; sort cutoffs
Shell SortO(n log n)O(n^1.25) – O(n^1.5)O(n²)O(1)——yesyesEmbedded; mid-size arrays without recursion
Radix SortO(d · (n + k))O(d · (n + k))O(d · (n + k))O(n + k)yes———Fixed-width keys: ints, strings, IPs