Sorting

Watch sorting algorithms run one operation at a time: which values get compared, which ones swap, and how the array settles into order.

Visualisations

Side by side

AlgorithmBestAverageWorstSpaceStable
Bubble SortO(n)O(n²)O(n²)O(1)Yes
Merge SortO(n log n)O(n log n)O(n log n)O(n)Yes
Radix SortO(nk)O(nk)O(nk)O(n + b)Yes
Counting SortO(n + k)O(n + k)O(n + k)O(n + k)Yes