So I'm currently learning 2D arrays in c++, I was solving this question which had a 2D array and we were to use sort inbuilt sort function of c++ with comparator, here's the code:
int getLights(vector<vector<int>>& lights) {
sort(lights.begin(),lights.end(),
[](const auto& a, const auto& b){
return a[0]==b[0] ? a[1]>b[1] : a[0]<b[0];
});
I'm not able to understand how this sort function works, can anyone help me get the output with this input:
lights = [[5,5],[6,3],[3,6]]