我想对 a 进行排序vector<vector<double> >
并记录原始索引vector<int>
ex A[0][1].............[N], and A[0][0] = X, A[0][1] = Y, A[0][2] = Z
A[0] = (1,5,3), A[1] = (3,2,1) A[2] = (2,8,4) after sorting
index: 0 1 2
A[0] = (1,5,3), A[1] = (2,8,4) A[2] = (3,2,1)
original index : 0 2 1
所以我写了下面的代码,我想用STL排序,但是不知道怎么写比较函数。
class point{
public:
point(int totalLength = 0, int elementLength = 0);
vector<vector<double> > pointSet;
vector<double> pointIndex;
};
point::point(int totalLength, int elementLength){
pointSet.resize(totalLength,vector<double>(elementLength, 0));
pointIndex.resize(elementLength);
}
和建议或其他方式来实现它?
感谢您的阅读。