Try Rail Yard Lab free in your browser, with nothing to install and no account. Program a switch engine with Blocks or Python and make the outbound freight train in station order. A side track is a stack: the engine can only reach the car nearest the switch, so a buried car has to be dug out. Every trip costs engine minutes, so two programs that both sort the train can cost very different amounts. Selection and insertion sort as real yard moves, why yards never swap two cars, and the famous Inglenook shunting puzzle, with the meters counting every trip.