Order by Last Digit — Solution & Editorial
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)
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)