how to sort my array of Custom Point class?
how to sort my array of Custom Point class? I am working on an algorithm that has to identify all pairs of 4 or more co-linear points and form the line segments between them without repetition. I am using a Point class to represent a point(x,y). It looks like this: public class Point { private final int x; // x-coordinate private final int y; // y-coordinate . ... ..... ...... } I have an array of Point class entities from which I have to identify whether the array has duplicate points(same points repeated more than once). I know there are so many ways like nesting for loops of depth 2. But I am interested in the sorting of that array in such a way that all the equal points should come first followed by unequal points in ascending order. Is it possible using the Comparator interface? Comparator Again: it's not possible with just sorting. You can sort your points, and then move blocks of equal points to the fron...