I'm trying to sort a List<Point2D>
of points using Collections.sort(). I believe I set up this comparator correct. Anyways, it's throwing an error saying: The method sort(List<T>, Comparator<? superT>) in the type Collections is not applicable for the arguments (List<Point2D>, new Comparator<Point2D.Double>(){})
. Does anybody understand why my compiler is throwing this error?
Collections.sort(points, new Comparator<Point2D.Double>() {
public int compare(Point2D.Double p1, Point2D.Double p2) {
return Double.compare(p1.getX(), p2.getX());
}
});