我想按距离变量对“mystruct”进行排序,最快的方法是什么?
struct MyStruct {
int scale;
bool pass;
float distance;
};
vector<MyStruct> mystruct;
...
sort (mystruct.begin(), mystruct.begin() + mystruct.size());
//this doesn't work since is trying to sort by "MyStruct" and not by a number
如果我有一个
vector<float> myfloat;
...
sort (myfloat.begin(), myfloat.begin() + myfloat.size());
然后将完美地工作。