c++ O(nlogn) time solution with explanation
The idea is splitting the logs into an id and a content and for that I used a struct called Log.\n\nclass Solution {\npublic:\n     struct Log{ \n      string i
The idea is splitting the logs into an id and a content and for that I used a struct called Log.\n```\nclass Solution {\npublic:\n     struct Log{ \n      string id;\n      string content;\n    };\n\t\n    struct Compare{ //a compare operator that will help us sort the letter logs\n      bool operator() (Log& l1, Log& l2){\n          return l1.content<l2.content || (l1.content==l2.content && l1.id<l2.id); //if the content is the same we sort them by their ids\n      }  \n    };\n\t\n    Log makeLog(string s) { //a function parsing the string into a Log type\n        Log l;\n        size_t i = s.find(\' \'); \n        l.id = s.substr(0, i); //splitting from position 0 to the first occurance of a space, that is the log id\n        l.content = s.substr(i+1, s.size() - i); //starting from position after the space till the end is the content\n        return l;\n    }\n    \n    string logToString(Log l){  //a function parsing a log back to string\n        return l.id + " " + l.content;\n    }\n    \n    vector<string> reorderLogFiles(vector<string>& logs) {\n\t\tCompare comp;\n        vector<Log> letterLogs;\n        vector<Log> digitLogs;\n        vector<string> result;\n\t\t\n        for(int i = 0; i < logs.size(); i++){\n            Log l = makeLog(logs[i]);\n            if(isdigit(l.content[0])) //we check if the content starts with a digit, if so we add it to our digitLogs, otherwise to the letterLogs\n                digitLogs.push_back(l);\n            else   \n                letterLogs.push_back(l); \n        }\n\t\t\n        sort(letterLogs.begin(), letterLogs.end(), comp); //we only need to sort the letter logs\n        \n        for(int i = 0; i < letterLogs.size(); i++){ //we add the sorted letter logs to the result\n            string str = logToString(letterLogs[i]);\n            result.push_back(str);\n        }\n        \n        for(int i = 0; i < digitLogs.size(); i++){ //we then add the digit logs to the result while maintaining their initial order\n            string str = logToString(digitLogs[i]);\n            result.push_back(str);\n        }\n        return result;\n    }\n};\n```\n\n**If you like this solution, upvotes would be appreciated!!**
['C', 'Sorting']