Loading

The Where-used atlas

Sorting algorithms, and where each is used

Every sort puts items in order; they differ in speed, in the memory they need, and in whether equal items keep their first order (a stable sort).

SortUse it whenReal example
Bubble sortyou are learning how sorting works, or a tiny list is almost sorted (with an early stop when a pass makes no swap)a first lesson in sorting
Insertion sortthe list is small or nearly sortedthe short runs that the hybrid sorts below sort first
Selection sortevery write is costly and the number of writes must be smallestmemory that wears out a little with every write
Merge sortthe sort must be stable or the data is too big for memorysorting a huge log file in chunks on disk and merging them
Quick sortgeneral sorting in memory where speed on average matters mostthe introsort behind C++'s std::sort, which starts as quick sort
Heap sorta guaranteed speed with no extra memory is neededa heap also keeps the top k items: the ten highest scores of a long contest
Timsortreal data that already holds runs in orderPython's sorted() and list.sort(), and JavaScript's Array.prototype.sort in V8 since v7.0 (Chrome 70)
Counting sort and radix sortthe keys are whole numbers in a small range or keys of a fixed lengthexam marks from 0 to 100; six-digit PIN codes

Checked 2026-10-26 against: The Python documentation; The V8 blog, "Getting things sorted in V8"; cppreference.com.

All the tables