What you should do is use the following version of Sort:

static void sort(Object[] a, Comparator c);

The Comparator and Coordinate would be the following in your case.

static void sort(Object[] a, Comparator c);

The Comparator and Coordinate would be the following in your case.

```
class CoordinageComparator implements Comparator{
public int compare(Coordinate coordinate1, Coordinate coordinate2) {
return coordinate1.compareTo(cordinate2);
}
}
class Coordinate {
public double X;
public double Y;
public CompareTo(Coordinate c) {
if (c.X < this.X)
return -1;
else if (c.X > this.X)
return 1;
else
return 0;
}
}
```