C++ Solution Using Map
\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n\t   //map stores all key values in sorted order\n        map<string,ve
```\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n\t   //map stores all key values in sorted order\n        map<string,vector<string>> mp;\n        vector<string> temp;\n        vector<string> ans;\n        string id,sub;\n        int pos;          \n        for(string s:logs){            \n            pos = s.find(" ");\n\t\t\t//if first char after space is digit push it to a temp array\n            if(isdigit( s[pos+1] ) ) {\n                temp.push_back(s); \n                continue;\n            }\n            id=s.substr(0,pos);\n            sub = s.substr(pos + 1); \n            mp[sub].push_back(id);\n        }\n        \n        for(auto it=mp.begin();it!=mp.end();it++){\n            sort(it->second.begin(),it->second.end());\n            for(string s:it->second){\n               ans.push_back(s + " " +it->first);\n            }\n        }\n        for(string s:temp){\n            ans.push_back(s);\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']