Lexicographical order

Vector를 축 기준으로 정렬 할 때 사용 한 방법.

struct Vector2 { float x, y; }

std::vector<Vector2> points;

points.push_back(Vector2(1, 2));
...

std::sort(points.begin(), points.end(), [](const Vector2& v0, const Vector2& v1)
{
       return v0.x < v1.x || (v0.x == v1.x && v0.y < v1.y);
});

x축 먼저 확인 한 다음 두 값이 같다면 y축을 기준으로 정렬한다.