C++ stable_sort easy to understand
Updated 02/16/2021\nIt seems the problem is a little bit different now. I have updated the code below:\n\nbool myCompare(string a, string b){\n    int i = a.fin
`Updated 02/16/2021`\nIt seems the problem is a little bit different now. I have updated the code below:\n```\nbool myCompare(string a, string b){\n    int i = a.find(\' \');\n    int j = b.find(\' \');\n    if(!isdigit(a[i + 1]) && !isdigit(b[j + 1])) {\n        if (a.substr(i + 1) == b.substr(j + 1)) return a < b;\n        return a.substr(i + 1) < b.substr(j + 1);\n    } else if (!isdigit(a[i + 1])) return true;\n    return false;\n}\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n        stable_sort(logs.begin(), logs.end(), myCompare);\n        return logs;\n    }\n};\n```\n\n`Original Solution`\n\n```\n\nbool myCompare(string a, string b){\n    int i = a.find(\' \');\n    int j = b.find(\' \');\n    if(!isdigit(a[i + 1]) && !isdigit(b[j + 1]))\n        return a.substr(i + 1) < b.substr(j + 1);\n    else{\n        if(!isdigit(a[i + 1])) return true;\n        return false;\n    }\n}\nclass Solution {\npublic:\n    vector<string> reorderLogFiles(vector<string>& logs) {\n        stable_sort(logs.begin(), logs.end(), myCompare);\n        return logs;\n    }\n};\n```
[]