C++ STL provides a function sort that sorts a vector or array (items with random access)
It generally takes two parameters, the first being the point of the
array/vector from where the sorting needs to begin and the second
parameter being the length to which we want the array/vector to get
sorted. The third parameter is optional and can be used in cases where
we want to sort the elements lexicographically.
By default, the sort() function sorts the elements in ascending
order.
How to sort in a particular order?
We can also write our own comparator function and pass it as a third
parameter. This “comparator” function returns a value; convertible to
bool, which basically tells us whether the passed “first” argument
should be placed before the given “second” argument or not.
Source: Sort C STL
The function you have written as the 3rd argument act as a comparator (it is a lambda expression), which returns a boolean value.
return a[0]==b[0] ? a[1]>b[1] : a[0]<b[0];
This statement basically compares the elements of a and b, if 1st element is the same check for the second element. It returns the smallest of the two numbers with respect to the 1st element of both arrays.
Output: [[3,6],[5,5],[6,3]]