I have a very basic C++ question. But I didn't find an appropriate answer after my own search. I saw some C++ code written like this:
sort(a.begin(), a.end(), [](auto &a, auto &b){return a[0] < b[0];});
ais a variable of typevector<vector<int>>.a[i][0]means the key of theith elementthe purpose of those code is to sort
aby keySo we need to pass a self defined compare function when calling "sort()"
the self defined compare function is defined by these codes:
[](auto &a,auto &b){return a[0] < b[0];}
I've never seen this way of writing (just like a lambda function in C++!), could you tell me how to understand these code?