Sorting · Dashboard

Compare every algorithm

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

AlgorithmBestAverageWorstMemoryStableRecursiveCache friendlyAdaptiveTypical usage
Counting SortO(n + k)O(n + k)O(n + k)O(n + k)yesyesSmall integer keys; radix building block
Bucket SortO(n + k)O(n + k)O(n²)O(n + k)yesUniformly distributed floats
Merge SortO(n log n)O(n log n)O(n log n)O(n)yesyesExternal sorting; linked lists; stable sorts
Quick SortO(n log n)O(n log n)O(n²)O(log n)yesyesGeneral-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)yesyesyesStdlib default (Python, Java, V8)
Bubble SortO(n)O(n²)O(n²)O(1)yesyesyesTeaching; detecting already-sorted data
Selection SortO(n²)O(n²)O(n²)O(1)yesMinimizing writes (EEPROM/flash)
Insertion SortO(n)O(n²)O(n²)O(1)yesyesyesSmall 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)yesFixed-width keys: ints, strings, IPs