Sort Target
Algorithm
Input
An input that partitions evenly. Pivot selection and delegation work as intended — this algorithm's usual flow
Speed
Normal ~12s · 42 ms/step
PDQ sort (branchless)(2016)
▶ Try this Source
O(n log n) ✗ Stable ✓ In-place
🔧 How it works

A Pattern-defeating quicksort variant that replaces the comparison-driven partition loop with branch-free classification into offset buffers (derived from BlockQuicksort), then exchanges misplaced pairs via cyclic permutation. Pattern detection, ninther pivot selection, equal-block skip, and heapsort fallback are otherwise identical to Pattern-defeating quicksort.

🎯 Key property

Eliminates data-dependent branches in the partition step, yielding substantially faster performance on random and duplicate-heavy inputs at the cost of overhead on small or perfectly predictable inputs (sorted, reversed).

👁 Watch for
  • Compare (pattern detection) same early-order scan as Pattern-defeating quicksort; already-partitioned ranges skip the block machinery entirely
  • Compare + Swap (branchless block partition) elements are classified into offset buffers without branching, then misplaced pairs are swapped in batch — fewer mispredicted branches than classic PDQSort on random data
  • Swap (heapsort fallback) / IndexWrite (insertion sort finish) identical reactive fallbacks when depth limit or small-array threshold is hit
Initial State
This is the array before sorting. Follow PDQ sort (branchless) step by step.
Recursion Tree
[0..31)51736248139151114101216211723192218202429253127302628
0 / 286 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 🗙