Cut the row in half. Cut those halves in half. Keep going until every piece is a single number, which is trivially sorted on its own. None of that took any real work — the work is all in what happens next: weaving two already-sorted runs back together, one comparison at a time, always taking whichever front value is smaller. Do that all the way back up and the whole array arrives sorted, and it arrives sorted no matter how scrambled it started. Step through a full split-then-merge below against the live pseudocode.

Leave a Reply