My question maybe related to this question - Encapsulating Internal Data Structure
I have a class LCTile.java which contains a Coordinate.java class. Coordinate.java that contains latitude and longitude(essentially a Point2D.java). Now I wish to sort the coordinates by latitude or longitude for which I have already developed a CoordinateComparator class. The Java API requires you pass in the List to be sorted and the Comparator i.e. Collections.sort(List list ,Comparator comparator). My question is the following - In order to sort the various tiles by latitude or longitude I have to obtain all the coordinate classes in a list from the original LCTile class and then pass them to the Collections.sort interface and then map them back to the original tile(s) after the sort operation is over. Is the encapsulation of the Coordinate class inside the LCTile absolutely essential or can this be done in a different way ?