Hi Guys,
I'm trying to figure out how I would sort a struct by a member value.
In this case I have 3 points of a triangle and I want to sort them from lowest to highest given their y position.
I have gotten as far as the code below but it gives me Error C2672 'operator __surrogate_func': no matching overloaded function found.
I know the code isn't quite right but I'm not too sure where to go from here.
Any help would be greatly appreciated.
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <string_view>
struct POINT
{
int x, y;
};
struct TRIANGLE
{
POINT a, b, c;
};
int main()
{
TRIANGLE tri;
tri.a = POINT{ 160, 125 };
tri.b = POINT{ 260, 100 };
tri.c = POINT{ 60, 175 };
std::array<TRIANGLE, 3> s = { tri.a.y, tri.b.y, tri.c.y };
std::sort(s.begin(), s.end());
}