Problems > Order by Last Digit > Editorial

Order by Last Digit — Solution & Editorial

Back to the Problem

Sort with the composite key: (x mod 10, x). Stability/tie-breaks come from including the value itself in the key.

Complexity: O(N log N · key cost)