code: public static final <T> int compare(T o1, T o2, Comparator<T> comp)
      {
          if (comp != null)
          {
              return comp.compare(o1, o2);
          }
          else
          {
              return ((Comparable<T>)o1).compareTo(o2);
          }
      }
docs: If comp is not null compares using it. Otherwise assumes o1 is
  Comparable<T>.
  @param <T>
  @param o1
  @param o2
  @param comp
  @return