sort.cny.shStart a race

The quiet of putting things in order.

Eighteen sorting algorithms, animated bar-by-bar and scored with Web Audio.

Sorting/bubble sort
n = 32
02The library

A catalog of eighteen
ways to make a line.

Each one annotated with its best, average, and worst complexity — plus whether it's stable, in-place, or both. Click any card to watch it work.

Stable — preserves equal order
In-place — O(1) extra memory
Playful / chaotic
01 / 18

Bubble Sort

Repeatedly swap neighbors that are out of order.

AverageO(n²)
WorstO(n²)
Open
02 / 18

Insertion Sort

Grow a sorted prefix by inserting each element into place.

AverageO(n²)
WorstO(n²)
Open
03 / 18

Selection Sort

Find the smallest item remaining; put it at the front.

AverageO(n²)
WorstO(n²)
Open
04 / 18

Cocktail Shaker Sort

Bubble sort, but sloshing both directions each pass.

AverageO(n²)
WorstO(n²)
Open
05 / 18

Gnome Sort

A gnome walks the row, swapping backward until it fits.

AverageO(n²)
WorstO(n²)
Open
06 / 18

Shell Sort

Insertion sort on shrinking gaps — breaks up the O(n²) wall.

Average≈O(n^1.3)
WorstO(n²)
Open
07 / 18

Merge Sort

Divide in half, sort each half, merge them back.

AverageO(n log n)
WorstO(n log n)
Open
08 / 18

Quick Sort

Pick a pivot, partition, recurse. Fast in practice.

AverageO(n log n)
WorstO(n²)
Open
09 / 18

Heap Sort

Build a max-heap, repeatedly extract the top.

AverageO(n log n)
WorstO(n log n)
Open
10 / 18

Radix Sort (LSD)

Stable-bucket by digit, least significant first.

AverageO(nk)
WorstO(nk)
Open
11 / 18

Counting Sort

Tally each value, then fill the array back in order.

AverageO(n + k)
WorstO(n + k)
Open
12 / 18

TimSort

Hybrid adaptive mergesort — what V8, lodash, Ramda, and Python actually use.

AverageO(n log n)
WorstO(n log n)
Open
13 / 18

Bogo Sort

Shuffle until sorted. Joke algorithm — capped to stay polite.

AverageO((n+1)!)
Worstunbounded
Have a laugh
14 / 18

Sleep Sort

Just for fun: each value naps proportionally, then wakes up in order.

AverageO(n + max)
Worstdepends on the OS scheduler
Have a laugh
15 / 18

Quantum Bogosort

Just for fun: shuffle once, destroy the universe if it isn't sorted.

AverageO(n)
WorstO(n) — in the surviving branch
Have a laugh
16 / 18

Purge Sort

Just for fun: anything out of order is silently rewritten to fit.

AverageO(n)
WorstO(n)
Have a laugh
17 / 18

Slowsort

Just for fun: "multiply and surrender" — a parody of divide-and-conquer.

Averagesuper-polynomial
Worstsuper-polynomial
Have a laugh
18 / 18

Miracle Sort

Just for fun: check if it's sorted; if not, wait for cosmic rays.

Averageunbounded
Worstunbounded
Have a laugh