Im trying to sort a vector with points (x,y values), first by the x and then by the y value, this is my implementation, can someone tell me if this will work because Iam getting following error:
error: no matching function for call to object of type '__gnu_cxx::__ops::_Iter_less_iter'
Im guessing its from the std::sort in some way but im not 100% sure?
struct P {
float x, y;
P(float x_, float y_) : x(x_), y(y_) {}
};
std::vector<P> sortingPointsX(const std::vector<P> &p) {
std::vector<P> copyP = p;
std::sort(copyP.begin(), copyP.end(),
[](P * a, P * b) -> bool
{ return a->x < b->x);
std::sort(copyP.begin(), copyP.end(),
[](P * a, P * b) -> bool
{ return a->y < b->y);
return copyP
}