My question maybe related to this question - Encapsulating Internal Data StructureI 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 ? 
Collections.sort question
java;design;refactoring;collections
You can create a comparator that compares the coordinates of the tile. In java 8 there is a helper function for that:Comparator<LCTile> cmp = Comparator.comparing(         LCTile::getCoordinate,         CoordinateComparator.instance);Then you can pass that with the list of tiles to Collections.sort.