What does a c++ stl sort function like this mean

  sort(a.begin(), a.end(), [] (int a, int b) {
        return a > b;
    });

what does the 3rd parameter in this mean
source: solution of problem c in Codeforces Round #764 (Div. 3) Editorial - Codeforces

It’s the (at the time of writing) the “(3)” form from here:

https://en.cppreference.com/w/cpp/algorithm/sort

i.e. sort where the third parameter is the comparator, given here as a lambda.

Equivalent to:

sort(a.begin(), a.end(), std::greater<>());
2 Likes

what does the [] mean here???
thanks for reply.

1 Like

Reference to a function, ig.

2 Likes

That’s the captures portion of the lambda (empty in this example).

4 Likes