Super easy C++ map based solution beats 97%, with detailed explanation
The basic idea is to cut the prefix and append it to the string\'s end, then normal string comparison will give us the required behaviour (first check for the b
The basic idea is to cut the prefix and append it to the string\'s end, then normal string comparison will give us the required behaviour (first check for the body without prefix then check for the prefix in case of ties).\n```\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n        map<string, string> m;\n        vector<string> d;\n        for(string s: logs) {\n            int firstChar = s.find(\' \') + 1; // index of first char after prefix\n            string nop = s.substr(firstChar, s.size()-space)+s.substr(0, firstChar);  // move prefix to the end to get the required behavior when using string comparison\n            if(isdigit(nop[0])) {\n                d.push_back(s); // store digit logs in a separate vector\n            } else {\n                m.insert({nop, s});\n            }\n        }\n        vector<string> answer;\n\t\t// add char logs first\n        for(auto x: m) {\n            answer.push_back(x.second);\n        }\n\t\t//append digit logs\n        answer.insert(answer.end(), d.begin(), d.end());\n        return answer;\n    }\n};\n```
['C', 'C++']