A comparison function, which imposes a <i>total ordering</i> on some collection of objects. Comparators can be passed to a sort method (such as {@link Collections#sort(List,Comparator) Collections.sort} or {@link Arrays#sort(Object[],Comparator) Arrays.sort}) to allow precise control over the sort order. Comparators can also be used to control the order of certain data structures (such as {@link SortedSet sorted sets} or {@link SortedMap sorted maps}), or to provide an ordering for collections of objects that don't have a {@link Comparable natural ordering}.<p>