Skip to content
Projects

LabSorting algorithms

SortFusion

Watch eight sorting algorithms compare, swap and merge their way to order. Pause at any step, scrub the timeline, follow the pseudocode, or drop in your own numbers.

Source
SortSpaceStep back←Step forward→Back to startRNew arrayS
Sound onM

Press Space to sort, or step through with ← →.

  • Unsorted
  • Comparing
  • Swap / write
  • Pivot / minimum
  • In final place
  • Outside current range

Your own numbers

Commas or spaces between values, up to 200. Decimals and negatives work.

Live metrics

Ready

Compares

0

of 226

Swaps

0

of 127

Writes

0

of 0

Exec time

—

48 bars · Random · 498 steps

Quick Sort

Picks a pivot, partitions smaller values to its left and larger to its right, then recurses on each side.

unstablein-place
Best
O(n log n)
Average
O(n log n)
Worst
O(n²)
Space
O(log n)
quickSort(lo, hi):
if lo ≥ hi: return
move the middle item to hi as pivot
i ← lo
for j ← lo to hi − 1
if a[j] < pivot: swap a[i], a[j]; i++
swap a[i], a[hi] (pivot lands in place)
quickSort(lo, i − 1); quickSort(i + 1, hi)
Space
Sort / pause
← →
Step
R
Back to start
S
New array
M
Sound