There is a list of polygons List<Polygon> Polygons
defined by these classes.
How can I order that list, so that the polygon are ordered first by the X property of their Points and then by the Y property of their Points in an ascending order.
public class Polygon
{
public List<Point2D> Points;
}
public class Point2D
{
public double X;
public double Y;
}
Update: For example consider these polygons:
(A) (0, 0) -> (5, 1) -> (5, -3) -> (0, -3) -> (0, 0)
(B) (0, -10) -> (5, -9) -> (5, -13) -> (0, -13) -> (0, -10)
(C) (10, 0) -> (15, 1) -> (15, -3) -> (10, -3) -> (10, 0)
the sorted output:
(A) (0, -10) -> (5, -9) -> (5, -13) -> (0, -13) -> (0, -10)
(B) (0, 0) -> (5, 1) -> (5, -3) -> (0, -3) -> (0, 0)
(C) (10, 0) -> (15, 1) -> (15, -3) -> (10, -3) -> (10, 0)