public static List<Map.Entry<List<String>, List<double[]>>> sort(
Map<List<String>, List<Double>> mapForSort,
Map<List<String>, List<double[]>> valueMap,
List<SortOption> sortOptions, int topN) {
processIndex(sortOptions);
List<Map.Entry<List<String>, List<double[]>>> result = new ArrayList<Map.Entry<List<String>, List<double[]>>>();
SortedSet<Map.Entry<List<String>, List<Double>>> sortedSet = sortByValue(
mapForSort, sortOptions);
for (Map.Entry<List<String>, List<Double>> entry : sortedSet) {
List<String> key = entry.getKey();
List<double[]> value = valueMap.get(key);
if (value != null) {
Map.Entry<List<String>, List<double[]>> newEntry = new ImmutableEntry<List<String>, List<double[]>>(key, value);
result.add(newEntry);
if (topN > 0 && result.size() >= topN) {
break;
}
}
}
return result;
}