Short & Clean Java code using Array.sort
Approach\n Describe your approach to solving the problem. \nI am utilizing Arrays.sort inbuilt java function and tweaking the sort functionality according to th
# Approach\n<!-- Describe your approach to solving the problem. -->\nI am utilizing Arrays.sort inbuilt java function and tweaking the sort functionality according to the question.\n\n\n# Code\n```\nclass Solution {\n    public String[] reorderLogFiles(String[] logs) {\n        Arrays.sort(logs, (a, b)->{\n            int i = a.indexOf(" ");\n            int j = b.indexOf(" ");\n            \n            //if both are digit: sequence will be same, return 0;\n            if(Character.isDigit(a.charAt(i+1)) && Character.isDigit(b.charAt(j+1))) return 0;\n\n            //if first is digit & second is letter: swap is required, return 1;\n            if(Character.isDigit(a.charAt(i+1))) return 1;\n\n            //if first is letter & second is digit: return -1;\n            if(Character.isDigit(b.charAt(j+1))) return -1;\n\n            int val = a.substring(i+1).compareTo(b.substring(j+1));\n            if(val != 0){\n                return val;\n            }\n\n            return a.compareTo(b);\n        });\n\n        return logs;\n    }\n}\n```
['Sorting', 'Java']