在代码中sort(A.begin(),A.end());
其中 A
定义为 vector<pair<int,pair<int,int>>> A;
.
如果我调用 sort
方法,那么在什么基础上进行排序呢?
最佳答案
它将使用 operator <
进行比较对于 std::pair
, specified here .
它按字典顺序比较 first
上的元素元素优先,如果它们相等,则在 second
上元素。
此处给出复杂类型 pair<int,pair<int,int>>
, 给出 std::sort
可能是更好的主意算法自定义比较器。确保提供的仿函数满足 Compare 的要求概念,即严格弱排序。
关于c++ - 如何使用 vector<pair<int,pair<int,int>>> 进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35036877/