Post

Sort Algorithm Reference

A reference list of every sorting algorithm in the Algorithm Guide, grouped from the essentials to the joke sorts, with a short note on why each one matters.

Sort Algorithm Reference

Every sorting algorithm covered by the Algorithm Guide, grouped into five tiers, from the essentials every developer should know to the ones that exist only as jokes. Algorithms with a guide link to it; the rest are on the way.

Tier 1: The Essentials

The sorts taught in every computer science course and asked about in every interview.

AlgorithmWhy it mattersGuide
QuickSortThe standard divide-and-conquer sort, and the basis of most library sorts.QuickSort in Java
Merge SortA stable O(n log n) sort that shows recursion and divide-and-conquer clearly. Variants: recursive, no extra space, concurrent.Merge Sort in Java
Heap SortAn in-place O(n log n) sort that also teaches the heap data structure.Heap Sort in Java
Insertion SortThe best choice for small or nearly sorted inputs, and used inside hybrid sorts.Insertion Sort in Java
Bubble SortThe classic first sorting algorithm. Variant: recursive.Bubble Sort in Java
Selection SortThe other basic O(n²) sort. Variant: recursive.Selection Sort in Java

Tier 2: Important in Practice or Theory

The sorts behind standard libraries, the linear-time sorts that avoid comparisons, and one graph algorithm that every build system relies on.

AlgorithmWhy it mattersGuide
TimSortThe sort behind Java’s Arrays.sort(Object[]) and Python’s built-in sort.Coming soon
Dual-Pivot QuickSortThe sort behind Java’s Arrays.sort() for primitive types.Coming soon
IntrosortIntrospective sort, the algorithm behind C++ std::sort.Coming soon
Counting SortThe main non-comparison sort, with linear time.Coming soon
Radix SortDigit-by-digit sorting built on counting sort.Coming soon
Bucket SortDistribution sorting for uniformly spread data.Coming soon
Shell SortA historically important improvement on insertion sort, using gap sequences.Coming soon
Topological SortA graph algorithm rather than an array sort, but essential for dependency resolution and build systems.Coming soon

Tier 3: Well Known, More Specialised

Variations on the basic sorts, sorts built on other data structures, and sorts designed for parallel hardware.

AlgorithmWhy it mattersGuide
Dutch National Flag SortDijkstra’s 3-way partition, and a common interview problem.Coming soon
Tree SortSorting by inserting into a binary search tree.Coming soon
Priority Queue SortHeap sort written with Java’s PriorityQueue.Coming soon
Binary Insertion SortInsertion sort that uses binary search to find each position.Coming soon
Cocktail Shaker SortBubble sort that passes in both directions.Coming soon
Comb SortBubble sort with shrinking gaps.Coming soon
Cycle SortMakes the minimum possible number of writes.Coming soon
Pigeonhole SortSimilar to counting sort, for small key ranges.Coming soon
Bitonic SortA parallel sorting network used on GPUs and in hardware.Coming soon
Odd-Even SortBrick sort, a parallel-friendly sort.Coming soon
Pancake SortA famous puzzle, and the subject of Bill Gates’ only research paper.Coming soon
Patience SortImportant for its link to the longest increasing subsequence problem.Coming soon
Smooth SortDijkstra’s adaptive variant of heap sort.Coming soon
Gnome SortA simple teaching variant of insertion sort.Coming soon
Tournament SortSorting with a winner tree, used in external sorting.Coming soon
Wiggle Sort / Wave SortInterview problems that produce alternating high and low values rather than a true sorted order.Coming soon

Tier 4: Niche or Rarely Taught

Hybrids, curiosities and exercises that are worth knowing about but rarely used.

AlgorithmWhy it mattersGuide
Spread SortA hybrid radix sort used in Boost.Sort.Coming soon
Flash SortDistribution sorting by classifying elements into buckets.Coming soon
Library SortGapped insertion sort.Coming soon
Strand SortPulls out sorted sublists and merges them.Coming soon
Adaptive Merge SortMerge sort that adapts to existing runs in the data.Coming soon
Exchange SortA simple compare-and-swap sort, often confused with bubble sort.Coming soon
Circle SortRecursively swaps elements in a circle pattern.Coming soon
Bead SortGravity sort, interesting as a physical model.Coming soon
Linked List SortApplies sorting techniques to a linked list; more an exercise than a separate algorithm.Coming soon
Swap SortPlaces each element by counting smaller values, and only works on unique values.Coming soon
Dark SortThe version in TheAlgorithms/Java is essentially counting sort under another name.Coming soon

Tier 5: Jokes and What Not to Do

Sorts that exist to make a point, usually about how not to sort.

AlgorithmWhy it mattersGuide
BogosortShuffles until the array is sorted. The best-known joke sort.Coming soon
Stooge SortA famously inefficient recursive sort.Coming soon
SlowsortBuilt on purpose to be as slow as possible (“multiply and surrender”).Coming soon
Stalin SortA meme sort that deletes every element that is out of order.Coming soon
This post is licensed under CC BY 4.0 by the author.