//sort point array for Grahams scan algo to find convex hull internal static void SortedPoint2dListForGrahamScan(ref List <Point2d> ptList, int size) { for (int i = 1; i < size; ++i) { for (int j = i + 1; j < size; ++j) { int order = ValidateObject.CheckPointOrder(ptList[0], ptList[i], ptList[j]); // collinear if (order == 0) { if (DistanceBetweenPoints(ptList[0], ptList[0]) <= DistanceBetweenPoints(ptList[0], ptList[j])) { ChangePlaces(ref ptList, i, j); } } else if (order == 1) { ChangePlaces(ref ptList, i, j); } } } }