The Sorting Algorithms Library

Everything about sorting, properly explained

42 guides that answer the questions people actually ask — from what a sorting algorithm is, through complexity and cache behaviour, to what your language runs under the hood. Written for beginners, detailed enough for interviews.

42 guides 8 categories about 6 hours of reading Free · no sign-up
Start here

New to sorting? Read these three.

8 guides

Fundamentals

3 guides

Reference & Cheatsheets

12 guides

Algorithm Deep Dives

Bubble Sort Explained The classic teaching algorithm: how Bubble Sort works, why it is O(n²), and the one optimization that makes it adaptive. 6 min read Read guide Selection Sort Explained The algorithm that makes the fewest swaps: how Selection Sort works and when its minimal-write property is useful. 5 min read Read guide Insertion Sort Explained The card-player's algorithm: how Insertion Sort works, why it is adaptive, and why fast sorts switch to it for small arrays. 6 min read Read guide Merge Sort Explained The reliable divide-and-conquer sort: guaranteed O(n log n), stable, and the basis for external sorting of huge datasets. 7 min read Read guide Quick Sort Explained The fastest practical sort: how partitioning works, why pivot choice is everything, and how to avoid the O(n²) trap. 7 min read Read guide Heap Sort Explained The only comparison sort that is both O(n log n) guaranteed and in-place — how Heap Sort uses a binary heap to do it. 6 min read Read guide Shell Sort Explained How Shell Sort supercharges Insertion Sort with gap sequences, and why the gap choice determines its performance. 5 min read Read guide Counting Sort Explained How Counting Sort breaks the O(n log n) barrier for bounded integers — and the memory cost that limits where you can use it. 5 min read Read guide Radix Sort Explained How Radix Sort sorts huge integer arrays in linear-ish time by processing one digit at a time with a stable sub-sort. 6 min read Read guide Tim Sort Explained Why the world's most-used sort is a hybrid: how Tim Sort detects natural runs and merges them for blazing real-world speed. 7 min read Read guide Bucket Sort Explained How Bucket Sort achieves linear average time on uniformly distributed data by scattering elements into buckets. 5 min read Read guide Introsort Explained How Introsort blends Quick, Heap, and Insertion Sort to get Quick Sort's speed without its O(n²) worst case. 6 min read Read guide
6 guides

Comparisons

5 guides

Systems & Performance

4 guides

Language Implementations

2 guides

Interview & Career

2 guides

Learning & Tools

Reading is good. Watching is better.

Every algorithm in this library runs step by step in the visualiser — with live pseudocode, comparison counters and colour-coded states.

Launch the visualiser