collection = new ReprojectingFeatureCollection(collection, query
.getCoordinateSystemReproject());
}
// step two sort! (note this makes a sorted copy)
if (query.getSortBy() != null && query.getSortBy().length != 0) {
SimpleFeature array[] = collection.toArray(new SimpleFeature[collection.size()]);
// Arrays sort is stable (not resorting equal elements)
for (SortBy sortBy : query.getSortBy()) {
Comparator<SimpleFeature> comparator = DataUtilities.sortComparator(sortBy);
Arrays.sort(array, comparator);
}