即時通訊嘗試使用排序函數對排序列表進行排序,其中包含對比較它們的第二個值的列表。這是我在用的:使用排序功能根據函數對列表進行排序
std::sort(score_list.begin(), score_list.end(), compare_pair);
這是排序功能:
bool Highscore::compare_pair (std::pair<std::string, int> first, std::pair<std::string, int> second)
{
if (first.second<second.second) return true;
else return false;
}
和我收到此錯誤信息:
error: no matching function for call to ‘sort(std::list<std::pair<std::basic_string<char>, int> >::iterator, std::list<std::pair<std::basic_string<char>, int> >::iterator, <unresolved overloaded function type>)’
有什麼建議?謝謝
+1:mem_fun也是我最初的直覺 – Chubsdad