c++ – How to sort a vector <pair<int,pair<int,int> &gt;&gt; by second.second (third int)?

Question:

There is an assumption that it is possible to crank with sort(v.begin(), v.end(), cmp) , but I do not understand how the third parameter is involved / what does it mean (Google also did not clarify)

Answer:

This is a reference to a function of the form bool foo(const T& a, const T& b) , where T is the type of the elements of the vector being sorted.

The purpose of this function is to check if a and b in ascending order. In other words, does the value of a exceed that of b (in mathematical terms, does the condition a < b ).

Scroll to Top