The compare-and-exchange machine.
How do comparisons become sorted order?
Loading the experiment…
How do comparisons become sorted order?
Fit the mechanism and begin comparing.
Insertion sort grows a sorted prefix. A new key moves left through adjacent exchanges until its predecessor is no larger. The machine shows the exact resulting order after each comparison; equal keys keep their original order.
Exact stable insertion sort on four integer keys. A pulse includes one comparison and its conditional adjacent exchange. Keys are physical teaching tokens, not a timing model for a CPU.
Finish insertion sort for all four keys.
Sort the keys through adjacent comparisons.