A stack only releases its top, so draining it replays history backwards. Pop each value and write it into an array, and by the time the stack is empty the array holds everything in reverse order.
One pass, no swaps, no index math. This is why undo history replays your latest action first, and why a single stack pass is the cheapest way to reverse any sequence.