Sorting algorithms

Compare how algorithms order the same values through swaps, shifts, partitions, counting, and digit passes.

How should the data move?

Choose by the decision you want to understand

Each lesson names the situation it fits and the behavior worth watching.

Bubble Sort visualizer preview
Start hereSwap neighbors

Bubble Sort

Choose it when
Learning comparison sorts for the first time
Watch for
The largest unsorted value moves right after every pass.
Explore Bubble Sort
Selection Sort visualizer preview
BeginnerSelect a minimum

Selection Sort

Choose it when
Separating comparisons from writes
Watch for
Each pass performs many checks but at most one final swap.
Explore Selection Sort
Insertion Sort visualizer preview
BeginnerShift and insert

Insertion Sort

Choose it when
Understanding nearly sorted data
Watch for
A sorted prefix grows while larger values shift right.
Explore Insertion Sort
Merge Sort visualizer preview
IntermediateDivide and merge

Merge Sort

Choose it when
Learning stable O(n log n) sorting
Watch for
Small sorted runs combine without revisiting earlier decisions.
Explore Merge Sort
Quick Sort visualizer preview
IntermediatePartition around a pivot

Quick Sort

Choose it when
Understanding in-place divide-and-conquer
Watch for
Values move to the correct side before the pivot is fixed.
Explore Quick Sort
Heap Sort visualizer preview
IntermediatePromote and extract

Heap Sort

Choose it when
Connecting tree structure to array sorting
Watch for
The maximum repeatedly rises to the heap root, then leaves the heap.
Explore Heap Sort
Counting Sort visualizer preview
SpecializedCount and place

Counting Sort

Choose it when
Small integer ranges with repeated values
Watch for
Value frequencies replace pairwise comparisons.
Explore Counting Sort
Radix Sort visualizer preview
SpecializedSort one digit

Radix Sort

Choose it when
Fixed-width integers or identifiers
Watch for
Stable digit passes preserve the ordering earned earlier.
Explore Radix Sort
Bucket Sort visualizer preview
SpecializedDistribute and gather

Bucket Sort

Choose it when
Values spread across a known range
Watch for
Good bucket distribution turns one hard sort into several small ones.
Explore Bucket Sort