How spaghetti can sort numbers by height

A spaghetti sort turns each number into a physical length: a larger value gets a longer strand. Stand the strands upright on a level surface and lower a flat board across them. The longest strand reaches the board first; remove it, then continue lowering to expose the next-longest. Repeating that process gives the numbers in descending order.

The key idea is parallel comparison. A conventional sorting program compares pairs of values through a sequence of operations. Here, the strands’ heights collectively determine which value is largest, so the board acts like a shared measuring device rather than comparing numbers one pair at a time.

The physical setup does the work—and sets the limits

The apparent speed comes with a tradeoff: the values must be encoded as lengths, and the equipment must distinguish those lengths. If two numbers differ by a tiny amount, their strands must differ enough for the board and the person handling them to tell which touches first. Strands can bend, surfaces can be uneven, and measurement errors can change the order.

There is also a cost the simple demonstration can hide. Finding each next strand still requires detecting contact and removing it, one at a time. The method shifts effort from digital comparisons to physical preparation, precision, and handling; it is a useful illustration of parallel processing, not a practical replacement for software sorting.

That is the memorable twist: the “algorithm” is not just the rule for ordering numbers. It includes the physical system that makes many comparisons happen together.