Sort Target
Algorithm
Speed
Normal ~12s · 135 ms/step
Bubble sort(1956)
▶ Try this Source
O(n²) ✓ Stable ✓ In-place
🔧 How it works

Repeatedly compares adjacent pairs left-to-right and swaps them if they are in the wrong order, so each pass carries the largest unsorted value step by step to its correct position at the end.

🎯 Key property

The simplest O(n²) sort with no lookahead or memory, its very simplicity means it performs more redundant comparisons than any other straightforward sort.

👁 Watch for
  • Compare each adjacent pair is tested in sequence; when already in order the scan advances without any swap
  • Swap fires only when left > right, nudging the larger value exactly one step rightward
  • End of pass the rightmost unsorted element settles into its final position, shrinking the active region by one
Initial State
This is the array before sorting. Follow Bubble sort step by step.
Main Array
5
0
3
1
8
2
1
3
9
4
2
5
7
6
4
7
0 / 89 ops ( 0.0%) 0.0%
Sorting is
a spectacle.
Algorithms at work, in a daily vertical feed. Watch, play, challenge — and go deeper when you're ready.
Loading 0%
An unhandled error has occurred. Reload 🗙