/** Sort the ratings. */ private void sortRatings() { int[] invMap = new int[index]; for (int i = index - 1; i >= 0; i--) { invMap[i] = i; } Arrays.quickSort(0, index, new SortComparator(), new SortSwapper(invMap)); translationMap = new int[index]; for (int i = 0; i < invMap.length; i++) { translationMap[invMap[i]] = i; } }
/** * Sort the list-in-progress by the specified comparator. * * @param order The comparator. * @return The buidler (for chaining). */ public ScoredIdListBuilder sort(Comparator<ScoredId> order) { Preconditions.checkState(ids != null, "builder has been finished"); quickSort(0, size(), new SortComp(order), new SortSwap()); return this; }