Clean java solution
\nclass Solution {\n    public String[] reorderLogFiles(String[] logs) {\n        if (logs == null)\n            return new String[0];\n        \n        Arrays
```\nclass Solution {\n    public String[] reorderLogFiles(String[] logs) {\n        if (logs == null)\n            return new String[0];\n        \n        Arrays.sort(logs, new LogComparator());\n        return logs;\n    }\n}\n\nclass LogComparator implements Comparator<String> {\n    @Override\n    public int compare(String s1, String s2) {\n        String[] s1Parts = s1.split(" ");\n        String[] s2Parts = s2.split(" ");\n        \n        char s1FirstChar = s1Parts[1].charAt(0);\n        char s2FirstChar = s2Parts[1].charAt(0);\n        \n        //if both are digit logs\n        if (Character.isDigit(s1FirstChar) && \n            Character.isDigit(s2FirstChar)) {\n            return 0 ; //return in order received\n        }\n        //if both are letter logs\n        if (!Character.isDigit(s1FirstChar) && \n            !Character.isDigit(s2FirstChar)) {\n            //compare substring after identifier and space\n            String log1 = s1.substring(s1Parts[0].length() + 1);\n            String log2 = s2.substring(s2Parts[0].length() + 1);\n            \n            int result = log1.compareTo(log2);\n\t\t\t//if substrings are identical, compare the identifiers\n            return result != 0 ? result : s1Parts[0].compareTo(s2Parts[0]);\n        }\n        \n        //one digit and other letter log\n        return Character.isDigit(s1FirstChar) ? 1 : -1;\n    }\n}\n```
[]