tap for sound

Gravity Sort Visualization

Gravity Sort (bead sort) drops beads on rods like an abacus, so each row settles to its sorted length.

How it works

Gravity Sort imagines each value as a row of beads on vertical rods. Let the beads fall, and each rod's beads pile up at the bottom; reading the rows back gives the values in sorted order. In software, each step lets the beads fall one level.

In physical hardware all beads fall at once, so it could sort in time proportional to the largest value. Simulated, it needs memory for every bead (values × rods) and only works on positive integers, so it is a curiosity more than a practical sort.

What to watch for

Watch the values change shape as the beads settle: during the sort the picture isn't a shuffle of the original values at all.

Complexity

Best
n
Average
S
Worst
S
Extra space
n²
Stable
No

Race it

Same shuffle, same speed, one winner: Gravity vs Counting. Or open the studio to try other layouts, sizes and speeds, and make a video of it.

FAQ

Is Gravity Sort real?

Yes, it was published in 2002 as Bead Sort. It is natural in hardware or physics, but costly to simulate.

Why is it capped here?

Simulating every bead takes memory and time that grow with n², so the visualizer limits it to 360 elements.