Choose how to sort a row of crates and watch the algorithm compare and swap, the bill changes drastically with your choice.
A conveyor of numbered crates needs ordering. Pick a sorting strategy and run it; the crates compare and swap on the belt while you are charged for every comparison and every swap. The cheapest strategy for this exact row is par, beat it to clear the yard.
Sort Yard makes sorting-algorithm cost visible by letting you run different strategies on the same data.
Choosing a strategy and watching crates compare and swap on a belt is the study of sorting algorithms, the classic entry point to analysing how much work a method costs.
Being charged for every comparison and every swap is the original teaching device, and it is the right one.
Those two operations are precisely what algorithm analysis counts. Bubble sort is not slow because it looks clumsy but because its comparison count grows with the square of the input, and paying per comparison is the only way to feel the difference between that and a method that grows more gently — which is what time complexity measures.
Sort Yard makes sorting-algorithm cost visible by letting you run different strategies on the same data. It is an original, free browser game built in-house for PlayPendium.