Obtains the reverse order comparator @param the data type @param cmp the original comparator @return the reverse order comparator
(final Comparator<T> cmp)
| 41 | * @return the reverse order comparator |
| 42 | */ |
| 43 | public static <T> Comparator<T> getReverse(final Comparator<T> cmp) |
| 44 | { |
| 45 | return new Comparator<T>() |
| 46 | { |
| 47 | @Override |
| 48 | public int compare(T o1, T o2) |
| 49 | { |
| 50 | return -cmp.compare(o1, o2); |
| 51 | } |
| 52 | }; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * We use an array of Integer objects instead of integers because we need |