多次元ベクトルをソートしようとしていますが、このコードを使用すると途中でいくつかの問題が発生します最後の次元 (vec[ ][ ][0] から vec[ ][ ][5]) に基づいてベクトル vec を注文する方法はありますか?
int main(){
vector<vector<vector<int> > > vec (148995,vector<vector<int> >(7,vector <int>(6,0)));
order();
order2();
}
bool comparison_function(const std::vector<std::vector<int> >& v1,
const std::vector<std::vector<int> >& v2) {
return v1[5][0] > v2[5][0];
}
void order(){
std::sort(vec.begin(), vec.end(),comparison_function);
}
bool comparison_function2(const std::vector<std::vector<int> >& v1,
const std::vector<std::vector<int> >& v2) {
return v1[5][2] > v2[5][2];
}
void order2(){
std::sort(vec.begin(), vec.end(),comparison_function2);
}
現在の動作方法は、order() を呼び出してから order2() を呼び出すと、order() のすべての順序が失われ、すべてが order2() によって順序付けられます。
最終的には、vec[ ][ ][x] の 3 番目のブラケットを使用して、ベクトルの次元を別々に注文できる 6 つの注文関数が必要です。
助けてくれてありがとう。