private static void sort() {
Arrays.sort(points, 1, 100, new Comparator<P>() {
@Override
public int compare(P p1, P p2) {
double cp = cross_product(points[0], p1, p2);
return cp > 0 ? -1 : 1;
}
});
}
public static double cross_product(P p1, P p2, P p3) {
return (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x);
}
I met this problem when I'm implementing the graham-scan algo for convex hull.