LocationExtensions { public static List<Position> sortByDistance(final Position startPoint, final List<Position> geohashes, final MeasuringUnit unit) { final List<DistancePoint> distancePoints = getDistancePoints(startPoint, geohashes, unit); Collections.sort(distancePoints); final List<Position> geosorted = new ArrayList<>(); for (int i = 0; i < distancePoints.size(); i++) { geosorted.add(distancePoints.get(i).getPoint()); } return geosorted; }  static List<DistancePoint> getDistancePoints(final Position startPoint,
		final List<Position> geohashes, final MeasuringUnit unit); static String getGeohashFromIpAddress(final LookupService lookupService,
		final String ipAddress); static GeoHashPoint getGeoHashPoint(final LookupService lookupService,
		final String ipAddress); static List<Position> sortByDistance(final Position startPoint,
		final List<Position> geohashes, final MeasuringUnit unit); static List<Position> sortByDistanceInMeters(final Position startPoint,
		final List<Position> geohashes);  }
@Test public void testSortByDistance() { List<Position> geohashes = new ArrayList<>(); geohashes.add(new GeoHashPoint("u0vf2w1s5tsy")); geohashes.add(new GeoHashPoint("u0t3z7cnznrx")); geohashes.add(new GeoHashPoint("u0td0v9xnz28")); Position startPoint = new GeoHashPoint("u11fyhzqhp3c"); LocationExtensions.sortByDistance(startPoint, geohashes, MeasuringUnit.METER); geohashes = new ArrayList<>(); geohashes.add(new GeoHashPoint("u0z4")); geohashes.add(new GeoHashPoint("u1p1")); geohashes.add(new GeoHashPoint("u28j")); geohashes.add(new GeoHashPoint("u0zc4wp0k")); startPoint = new GeoHashPoint("u0ww"); LocationExtensions.sortByDistance(startPoint, geohashes, MeasuringUnit.METER); }