code: public static final Comparator<ScoringInfo> comparator(final ScoreKeeper.StoppingMetric criterion) {
      return new Comparator<ScoringInfo>() {
        @Override
        public int compare(ScoringInfo o1, ScoringInfo o2) {
          boolean moreIsBetter = ScoreKeeper.moreIsBetter(criterion);
  
          if (!moreIsBetter)
            return (int)Math.signum(o2.metric(criterion) - o1.metric(criterion));
          else
            return (int)Math.signum(o1.metric(criterion) - o2.metric(criterion));
        }
      };
    }
docs: Create a java.util.Comparator which allows us to sort an array of ScoringInfo based
  on a stopping criterion / metric.  Uses cross-validation or validation metrics if
  available, otherwise falls back to training metrics.  Understands whether more is
  better for the given criterion and will order the array so that the best models are
  last (to fit into the behavior of a model that improves over time)
  @param criterion scalar model metric / stopping criterion by which to sort
  @return a Comparator on a stopping criterion / metric