/** * Sorts a list of ranges into ascending order of min value, then max value. * * @param <T> the value type * @param ranges the ranges to sort */ public static <T extends Number & Comparable> void sortInPlace(List<Range<T>> ranges) { Collections.sort(ranges, new RangeComparator(new RangeExtendedComparator<T>())); }
public int compare(LookupItem<T, U> item1, LookupItem<T, U> item2) { return delegate.compare(item1.getRange(), item2.getRange()); } }
/** * Sorts a collection of ranges into ascending order of min value, then max value. * Returns a new List of sorted ranges, leaving the input collection unmodified. * * @param <T> the value type * @param ranges the ranges to sort * * @return sorted ranges as a {@code List} */ public static <T extends Number & Comparable> List<Range<T>> sort(Collection<Range<T>> ranges) { List<Range<T>> copy = new ArrayList<Range<T>>(ranges); Collections.sort(copy, new RangeComparator(new RangeExtendedComparator<T>())); return copy; }
Collections.sort(inputs, new RangeComparator(comparator)); do { changed = false;