Here's the overload of binarySearch() , which accepts a custom Comparator . Call it by going to a comparator that changes the usual comparison results.
For example, if you have a List<Integer> , then call:
int index = Collections.binarySearch<Integer>( intList, Integer.valueOf(1), Collections.reverseOrder());
(Using `Collections.reverseOrder () thanks @MarkPeters.)
source share