Can someone explain meaning of this paragraph
The great advantage of pairs is that they have built-in operations to compare themselves. Pairs are compared first-to-second element. If the first elements are not equal, the result will be based on the comparison of the first elements only; the second elements will be compared only if the first ones are equal. The array (or vector) of pairs can easily be sorted by STL internal functions.
and hence this
For example, if you want to sort the array of integer points so that they form a polygon, it’s a good idea to put them to the
vector< pair<double, pair<int,int> >
, where each element of vector is{ polar angle, { x, y } }
. One call to the STL sorting function will give you the desired order of points.
I have been struggling for an hour to understand this.
Source