参考
主要是用了std::sort 函数
这里只写一种lambda写法。
std::vector<std::map<std::string, std::string>> tempArr;
std::sort(tempArr.begin(), tempArr.end(), [](const map<string, string> &map1, const map<string, string> &map2) {
long t_value1 = atol(MySQLManager::sGetValue(map1, "WaitTime").c_str());
long t_value2 = atol(MySQLManager::sGetValue(map2, "WaitTime").c_str());
return t_value1 > t_value2;
});
传入函数指针的方式也很好,就怕遇到那种判断条件总是在变的情况,那时候要写很多,万一出问题,代码不好查看。