C++ (sorting with comparator)
\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n        vector<string> digit_logs;\n        vector<string> result;\n   
```\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n        vector<string> digit_logs;\n        vector<string> result;\n        for(string &log : logs) {\n            int idx      = log.find(\' \');\n            string check = log.substr(idx+1);\n            \n            //if digit log\n            if(check[0] >= \'0\' && check[0] <= \'9\') {\n                digit_logs.push_back(log);\n            } else {\n                result.push_back(log); //pushing letter logs first\n            }\n            \n        }\n        \n        auto lambda = [](string &a, string &b) {\n            int idx       = a.find(\' \');\n            string id1    = a.substr(0, idx);\n            string check1 = a.substr(idx+1);\n            \n            idx           = b.find(\' \');\n            string id2    = b.substr(0, idx);\n            string check2 = b.substr(idx+1);\n            \n            if(check1 == check2)\n                return id1 < id2;\n            \n            return check1 < check2;\n        };\n        \n        sort(begin(result), end(result), lambda);\n        \n        for(string &log : digit_logs)\n            result.push_back(log);\n        \n        return result;\n    }\n};\n```
[]