(C++) 937. Reorder Data in Log Files
\n\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n        vector<pair<string, string>> letter_logs; \n        vector<st
\n```\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n        vector<pair<string, string>> letter_logs; \n        vector<string> digit_logs; \n        for (auto log : logs) {\n            int i = log.find(\' \'); \n            if (isalpha(log[i+1])) \n                letter_logs.emplace_back(log.substr(0, i), log.substr(i+1)); \n            else \n                digit_logs.push_back(log); \n        }\n        \n        sort(letter_logs.begin(), letter_logs.end(), [&](auto& lhs, auto& rhs) {\n            return lhs.second < rhs.second || (lhs.second == rhs.second && lhs.first < rhs.first); \n        });\n        \n        vector<string> ans; \n        for (auto x : letter_logs) \n            ans.push_back(x.first + " " + x.second); \n        \n        ans.insert(ans.end(), digit_logs.begin(), digit_logs.end());\n        return ans; \n    }\n};\n```
['C']