← playground
Interactive · Sorting algorithms

Five ways to
order a list.

Every comparison, swap and write, recorded up front and played back frame by frame. Scrub the timeline, step one operation at a time, and watch where the O(n²) algorithms lose to the O(n log n) ones — and where they don’t.

Timeline
unsorted comparing pivot partially ordered final position
0
Comparisons
0
Swaps
0
Writes
0
of 0 operations
 

Bubble sort

stable

Best
Average
Worst
Space

Side by side

The tradeoffs that matter in practice: whether it allocates, whether equal elements keep their original order, and how badly the worst case hurts.

Algorithm Best Average Worst Space Stable Where it wins