Take logs = ["a1 9 2 3 1", "g1 act car", "zo4 4 7", "ab1 off key dog", "a8 act zoo"].
First, partition. Letter-logs: ["g1 act car", "ab1 off key dog", "a8 act zoo"]. Digit-logs: ["a1 9 2 3 1", "zo4 4 7"].
Sort letter-logs by content. "act car" < "act zoo" < "off key dog" lexicographically.
Sorted: ["g1 act car", "a8 act zoo", "ab1 off key dog"]. Append digit-logs in original order.
Result: ["g1 act car", "a8 act zoo", "ab1 off key dog", "a1 9 2 3 1", "zo4 4 7"].
Sorting costs where is letter-log count and is max log length. Partitioning is . Overall time, space.