Playground / Quick Sort

Partition around a pivot

Quick Sort

Interactive lab

Try it: Quick Sort

How quick sort (Lomuto partition) puts one pivot in its final place with everything smaller before it, then sorts each side.

How it works

  1. Choose the last value of the range as the pivot.
  2. Walk the range; move every value that belongs before the pivot to the front boundary.
  3. Swap the pivot to the boundary — its final place.
  4. Sort the left and right parts the same way; fast on average, slow on already-sorted input with this pivot choice.

Default run (22 steps): Quick sort (Lomuto), ascending: [8, 3, 5, 1, 9, 2]. … Sorted ascending: [1, 2, 3, 5, 8, 9] — 11 comparisons, 5 swaps.

Simplified: Up to 12 numbers from 0 to 99. The comparison table runs all five algorithms on the same input. Python's own sort() uses Timsort.

Educational simulation

Loading the simulation…