请教:sort( v.begin(), v.end(), [] ) 函数中的中括号[]是什么意思?->int又是什么意思?
我在网上搜了一个把字典按value而不是按key排序的小程序:
程序代码:int main() {
unordered_map<int, int> iMap;
iMap[1] = 20;
iMap[2] = 10;
iMap[5] = 30;
iMap[4] = 0;
vector<pair<int, int>> vtMap;
for (auto it = iMap.begin(); it != iMap.end(); it++)
vtMap.push_back(make_pair(it->first, it->second));
sort(vtMap.begin(), vtMap.end(), [](const pair<int, int> &x, const pair<int, int> &y) -> int{ return x.second < y.second; }); // 这一句是什么意思?
return 0;}
请问sort(vtMap.begin(), vtMap.end(), [](const pair<int, int> &x, const pair<int, int> &y) -> int{ return x.second < y.second; });这一句是什么意思?[](pair, pair)怎么理解?-> int又怎么理解?
谢谢!







