Java Solution - Beats 99% both runtime and memory
\nclass Solution {\n    public String[] reorderLogFiles(String[] logs) {\n        if(logs.length == 0) return logs;\n        List<String> letterLogs = new Array
```\nclass Solution {\n    public String[] reorderLogFiles(String[] logs) {\n        if(logs.length == 0) return logs;\n        List<String> letterLogs = new ArrayList<>(), digitLogs = new ArrayList<>();\n        separateLettersDigits(logs, letterLogs, digitLogs);\n        sortLetterLogs(letterLogs);\n        return generateOutput(letterLogs, digitLogs);  \n    }\n    \n    void separateLettersDigits(\n        String[] input, \n        List<String> letterLogs, \n        List<String> digitLogs\n    ) { \n        for(String log : input) {\n            if(Character.isDigit(log.charAt(log.length()-1))){\n                digitLogs.add(log);\n            } else {\n                letterLogs.add(log);\n            }\n        }\n    }\n    \n    void sortLetterLogs(\n        List<String> letterLogs\n    ) {\n        Collections.sort(letterLogs, new Comparator<String>() {\n            public int compare(String o1, String o2) {\n\t\t\t    String s1 = o1.substring(o1.indexOf(" ") + 1);\n\t\t\t    String s2 = o2.substring(o2.indexOf(" ") + 1);\n                \n                return s1.equals(s2) ? o1.compareTo(o2) : s1.compareTo(s2);\n            }\n        });\n    }\n    \n    String[] generateOutput(\n        List<String> letterLogs, \n        List<String> digitLogs\n    ) {\n        String[] output = new String[letterLogs.size() + digitLogs.size()];\n        for(int i = 0; i < letterLogs.size(); i++) {\n            output[i] = letterLogs.get(i);\n        }\n        for(int i = letterLogs.size(); i < output.length; i++) {\n            output[i] = digitLogs.get(i-letterLogs.size());\n        }\n        return output;  \n    }\n}\n```
['Java']