C++ 内部有2对向量的排序

C++ 内部有2对向量的排序,c++,algorithm,sorting,vector,std-pair,C++,Algorithm,Sorting,Vector,Std Pair,我有一个向量,pair>,我想知道他是怎么排序的?使用排序(v.begin(),v.end()) 输出: 0 20 20 0 5 15 15 5 5 19 8 17 8 10 10 8 如果所包含的类型支持通过类std::pair的运算符进行比较,则定义 template<class T1, class T2> constexpr bool operator< (const pair<T1, T2>&, const pair<T1, T2>&a

我有一个向量,pair>,我想知道他是怎么排序的?使用排序(v.begin(),v.end())

输出:

0 20 20 0
5 15 15 5
5 19 8 17
8 10 10 8

如果所包含的类型支持通过类
std::pair
运算符进行比较,则定义

template<class T1, class T2>
constexpr bool operator< (const pair<T1, T2>&, const pair<T1, T2>&);


首先,使用相同的
操作符从左到右排序来比较对
{5,19}
{5,15}
:首先是x1,如果是并列的y1,然后是如果是并列的x2,然后是如果是并列的y2。
0 20 20 0
5 15 15 5
5 19 8 17
8 10 10 8
template<class T1, class T2>
constexpr bool operator< (const pair<T1, T2>&, const pair<T1, T2>&);
{ { 5, 19 }, { 8, 17 } }
  ^^^^^^^^^
{ { 5, 15 }, { 15, 5 } }
  ^^^^^^^^^
{ { 5, 15 }, { 8, 17 } }
  ^^^^^^^^^
{ { 5, 15 }, { 15, 5 } }
  ^^^^^^^^^