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).
| Sort | Use it when | Real example |
|---|---|---|
| Bubble sort | you 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 sort | the list is small or nearly sorted | the short runs that the hybrid sorts below sort first |
| Selection sort | every write is costly and the number of writes must be smallest | memory that wears out a little with every write |
| Merge sort | the sort must be stable or the data is too big for memory | sorting a huge log file in chunks on disk and merging them |
| Quick sort | general sorting in memory where speed on average matters most | the introsort behind C++'s std::sort, which starts as quick sort |
| Heap sort | a guaranteed speed with no extra memory is needed | a heap also keeps the top k items: the ten highest scores of a long contest |
| Timsort | real data that already holds runs in order | Python's sorted() and list.sort(), and JavaScript's Array.prototype.sort in V8 since v7.0 (Chrome 70) |
| Counting sort and radix sort | the keys are whole numbers in a small range or keys of a fixed length | exam 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.