Cee/Leetcode

Your solution doesn't compare the id when two logs have exactly the same words after the id.

JinZhenlin opened this issue · 0 comments

Collections.sort(letters, (a, b) -> (a.log.compareTo(b.log)));

The leetcode problem states that

The letter-logs are ordered lexicographically ignoring identifier, with the identifier used in case of ties.

Therefore, in the example of input- ["a1 9 2 3 1","g1 act car","zo4 4 7","ab1 off key dog","a8 act zoo","a2 act car"]

The expected output should be- ["a2 act car","g1 act car","a8 act zoo","ab1 off key dog","a1 9 2 3 1","zo4 4 7"]

However this solution outputs- ["a2 act car","g1 act car","a8 act zoo","ab1 off key dog","a1 9 2 3 1","zo4 4 7"]