[Java]  clear explanation | lamda Arrays.sort()
\nclass Solution {\n    public String[] reorderLogFiles(String[] logs) {\n        Arrays.sort(logs, (log1, log2) -> {\n            String[] log1Array = log1.spl
```\nclass Solution {\n    public String[] reorderLogFiles(String[] logs) {\n        Arrays.sort(logs, (log1, log2) -> {\n            String[] log1Array = log1.split(" ", 2);\n            String[] log2Array = log2.split(" ", 2);\n            boolean isDigit1 = Character.isDigit(log1Array[1].charAt(0));\n            boolean isDigit2 = Character.isDigit(log2Array[1].charAt(0));\n            \n            if(isDigit1 && isDigit2) { // both are digits\n                return 0;\n            } else if(isDigit1 && !isDigit2) { // string2 in front of digit1\n                return 1;\n            } else if(!isDigit1 && isDigit2) { // string1 in front of digit2\n                return -1;\n            }\n            // else both are strings\n            int compare = log1Array[1].compareTo(log2Array[1]);\n            \n            // if string1 == string2, return identifier comparator\n            return compare == 0 ? log1Array[0].compareTo(log2Array[0]) : compare;\n        });\n        return logs;\n    }\n}\n```
['Java']