Я пытаюсь сортировать std::vector
, используя algorithm::sort
, но я получаю ошибку во время выполнения
Invalid operator <
.
Ниже приведен мой код.
struct Point {
double x_cord;
double y_cord;
int id;
Point(int d, double x, double y) {
x_cord = x;
y_cord = y;
id = d;
}
};
struct compareX {
bool operator ()(Point * left, Point* right) const {
if (left->x_cord < right->x_cord)
return true;
return true;
}
};
struct compareY {
bool operator ()(Point * left, Point* right) const {
if (left->y_cord <= right->y_cord) return true;
return true;
}
};
Вот теперь я вызываю его после заполнения значений.
std::sort( posVector.begin(), posVector.end(), compareX());