public static <T>T min(Collection<? extends T> collection,Comparator<? super T> comparator){
  if (comparator == null) {
    @SuppressWarnings("unchecked") T result=(T)min((Collection<Comparable>)collection);
    return result;
  }
  Iterator<? extends T> it=collection.iterator();
  T min=it.next();
  while (it.hasNext()) {
    T next=it.next();
    if (comparator.compare(min,next) > 0) {
      min=next;
    }
  }
  return min;
}

public static < T > T min ( Collection < ? extends T > collection , Comparator < ? super T > comparator ) { if ( comparator == null ) { @ SuppressWarnings ( "unchecked" ) T result = ( T ) min ( ( Collection < Comparable > ) collection ) ; return result ; } Iterator < ? extends T > it = collection . iterator ( ) ; T min = it . next ( ) ; while ( it . hasNext ( ) ) { T next = it . next ( ) ; if ( comparator . compare ( min , next ) > 0 ) { min = next ; } } return min ; }
searches the specified collection for the minimum element using the specified comparator .
