Sorting Algorithm Race

Four sorting algorithms, one shuffled array, all four running at once. Every lane gets the same number of array operations per second, so the finish order is simply who needs less work. Try Nearly sorted — the two "slow" algorithms suddenly win.

Bubble sort

O(n²) ready
compares
0
writes
0
total ops
0

Insertion sort

O(n²) ready
compares
0
writes
0
total ops
0

Merge sort

O(n log n) ready
compares
0
writes
0
total ops
0

Quick sort

O(n log n) ready
compares
0
writes
0
total ops
0

Starting array

Operations handed to every lane each second — identical for all four.

Key

comparing two values
writing a value
finished, checked sorted

Every lane starts from the same array. Total ops counts each comparison plus each element written — a swap is two writes.