📍Modern C++ STL way in just 8 lines
\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n        // We can break this problem into two tasks: 1) Parition 2) Sor
```\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n        // We can break this problem into two tasks: 1) Parition 2) Sort letter-logs\n\n        // Partition: letter-logs at the front, digit-logs at the back.\n        // We\'re using stable_partition instead of partition to retain the original order.\n        // stable_partition returns an iterator to the first element of the second group.\n        \n        auto it = stable_partition(logs.begin(), logs.end(), [](const string& str) {\n            return isalpha(str[str.find(\' \') + 1]);\n        });\n\n        // Sort letter-logs: We\'re only iterating on letter-logs in this case.\n        // We\'re creating a substring for every element we compare that doesn\'t include the identifier\n        // If the logs are the same except the identifier, we compare the strings, otherwise, the substrings\n        \n        sort(logs.begin(), it, [](const string& str1, const string& str2) {\n            auto substr1 = string(str1.begin() + str1.find(\' \'), str1.end());\n            auto substr2 = string(str2.begin() + str2.find(\' \'), str2.end());\n            return (substr1 == substr2) ? str1 < str2 : substr1 < substr2;\n        });\n        \n        return logs;\n    }\n};\n```
[]