C++:对map按value排序例子

map bet;
vector> a(bet.begin(), bet.end());
sort(a.begin(), a.end(), [](const pair& lhs, const pair& rhs){return lhs.second > rhs.second;});

将map存储在vector中,然后利用sort,传入比较pair中的second(也就是value)的lambda表达式,得到结果。

你可能感兴趣的:(C++:对map按value排序例子)