Why Undo takes back the newest edit.
transcript
Press Undo in any editor. The last thing you did disappears. Press it again. The one before goes. Newest first. Never the oldest.
Think of every edit as a plate. A new edit goes on top of the pile. Now edit four is on top. Undo takes the top one off. Press again, and edit three goes. Edit one waits at the bottom, safe and untouched.
Add only on top. Remove only from the top. Nothing in the middle is within reach. So the newest value always leaves first.
We call this last in, first out. Push adds a value on top. Pop removes the top value. Peek reads it without removing.
Undo history is a stack of edits. The back button is a stack of pages. And every program has a call stack. Same rule, three very different places.
One rule: newest first. Push and pop cost one step. Try it in the sandbox. Full breakdown in the lecture.