假设我有这个向量向量[[5,10],[2,5],[4,7],[3,9]],我想使用sort()cpp的方法对它进行排序,这样[[5,10],[3,9],[4,7],[2,5]]排序后就变成这样了。那就是我想根据第二个索引进行排序。
现在我已经编写了这段代码来对向量的向量进行排序,但它无法正常工作。
static bool compareInterval( vector<vector<int>> &v1, vector<vector<int>> &v2)
{
return (v1[0][1]>v2[0][1]);
}
sort(boxTypes.begin(), boxTypes.end(), compareInterval);
Run Code Online (Sandbox Code Playgroud)
谁能告诉我哪里出了问题,我该如何纠正。提前致谢。