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

Alternates between an odd phase that compares pairs at positions (0,1), (2,3), … and an even phase that compares pairs at positions (1,2), (3,4), …, repeating until a full round completes with no swaps.

🎯 Key property

Within each phase all pair comparisons are independent of one another, making it directly parallelisable, each phase can be executed in a single parallel step on hardware with enough processors.

👁 Watch for
  • Compare odd phase tests every other pair starting at index 0; even phase shifts the pattern by one and tests the interleaved pairs
  • Swap fires independently at any pair where left > right; multiple swaps can occur in the same phase without interfering with each other
  • End of round one odd phase and one even phase together form one round; rounds repeat until no swap fires in either phase
Initial State
This is the array before sorting. Follow Odd-even sort step by step.
Main Array
5
0
3
1
8
2
1
3
9
4
2
5
7
6
4
7
0 / 77 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 🗙