Get a {@link Collector} that calculates the <code>MEDIAN()</code> function given a specific ordering.
336233
public static <T, U extends Comparable<? super U>> Collector<T, ?, Optional<U>> median(Function<? super T, ? extends U> function) {
        return percentile(0.5, function);
    }
181671
public static <T, U> Collector<T, ?, Integer> bitOrInt(ToIntFunction<? super T> function) {
        return Collector.of(() -> new int[1],
            (s, v) -> {
                s[0] = s[0] | function.applyAsInt(v);
            },
            (s1, s2) -> {
                s1[0] = s1[0] | s2[0];
                return s1;
            },
            s -> s[0]
        );
    }
431490
@SuppressWarnings("rawtypes")
    public static <T, R> Collector<T, ?, R> streaming(final Function<? super Stream<T>, R> streamingCollector) {
        return streaming((Supplier) queueSupplier, streamingCollector);
    }
1194719
@Override
    public <R, A> R collect(Collector<? super T, A, R> collector) {
        Predicate<A> finished = finished(collector);
        if (finished != null) {
            BiConsumer<A, ? super T> acc = collector.accumulator();
            BinaryOperator<A> combiner = collector.combiner();
            Spliterator<T> spliterator = spliterator();
            if (!isParallel()) {
                A a = collector.supplier().get();
                if (!finished.test(a)) {
                    try {
                        // forEachRemaining can be much faster
                        // and take much less memory than tryAdvance for certain
                        // spliterators
                        spliterator.forEachRemaining(e -> {
                            acc.accept(a, e);
                            if (finished.test(a))
                                throw new CancelException();
                        });
                    } catch (CancelException ex) {
                        // ignore
                    }
                }
                return collector.finisher().apply(a);
            }
            Spliterator<A> spltr;
            if (!spliterator.hasCharacteristics(Spliterator.ORDERED)
                || collector.characteristics().contains(Characteristics.UNORDERED)) {
                spltr = new UnorderedCancellableSpliterator<>(spliterator, collector.supplier(), acc, combiner,
                        finished);
            } else {
                spltr = new OrderedCancellableSpliterator<>(spliterator, collector.supplier(), acc, combiner, finished);
            }
            return collector.finisher().apply(
                new StreamEx<>(StreamSupport.stream(spltr, true), context).findFirst().get());
        }
        return rawCollect(collector);
    }
863818
public static <T> Collector<T, ?, Optional<Double>> percentRank(T value, Comparator<? super T> comparator) {
        return percentRankBy(value, t -> t, comparator);
    }
431762
public static <T> Collector<T, ?, Optional<Long>> rank(T value, Comparator<? super T> comparator) {
        return rankBy(value, t -> t, comparator);
    }
740627
public static <T> Collector<T, ?, Seq<T>> maxAll(Comparator<? super T> comparator) {
        return maxAllBy(t -> t, comparator);
    }
63404
@NotNull
    public static <T> Collector<T, ?, Integer> summingInt(@NotNull final ToIntFunction<? super T> mapper) {
        return new CollectorsImpl<T, int[], Integer>(

                new Supplier<int[]>() {
                    @NotNull
                    @Override
                    public int[] get() {
                        return new int[] { 0 };
                    }
                },

                new BiConsumer<int[], T>() {
                    @Override
                    public void accept(int[] t, T u) {
                        t[0] += mapper.applyAsInt(u);
                    }
                },

                new Function<int[], Integer>() {
                    @Override
                    public Integer apply(int[] value) {
                        return value[0];
                    }
                }
        );
    }
925380
public static <T, U> Collector<T, ?, Seq<U>> maxAll(Function<? super T, ? extends U> function, Comparator<? super U> comparator) {
        return collectingAndThen(maxAllBy(function, comparator), t -> t.map(function));
    }
296751
public static int median(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator) {
    return median(data, comparator, 0, data.size());
  }
1122124
function getComparator(sortOrder) {
  if (typeof sortOrder === 'function') {
    return sortOrder;
  }

  const comparators = {
    [ASC]: ascendingSort,
    [DESC]: descendingSort,
    [ASC_LENGTH]: lengthSort,
    [DESC_LENGTH]: lengthReverseSort
  };

  return comparators[sortOrder];
}
69704
@SuppressWarnings("unchecked")
   public static <T, R> Supplier<Collector<T, ?, R>> toSupplierCollect(Supplier supplier) {
      return supplier;
   }
358454
public Comparator<Integer> getCompByName() {
    return new Comparator<Integer>() {
      @Override
      public int compare(Integer t1, Integer t2) {
        Integer p1 = tokenCollection.get(t1).getPositionStart();
        Integer p2 = tokenCollection.get(t2).getPositionStart();
        assert p1 != null : "no position for " + tokenCollection.get(t1);
        assert p2 != null : "no position for " + tokenCollection.get(t2);
        if (p1.equals(p2)) {
          Integer o1 = tokenCollection.get(t1).getOffsetStart();
          Integer o2 = tokenCollection.get(t2).getOffsetStart();
          if (o1 != null && o2 != null) {
            if (o1.equals(o2)) {
              return tokenCollection.get(t1).getValue()
                  .compareTo(tokenCollection.get(t2).getValue());
            } else {
              return o1.compareTo(o2);
            }
          } else {
            return tokenCollection.get(t1).getValue()
                .compareTo(tokenCollection.get(t2).getValue());
          }
        }
        return p1.compareTo(p2);
      }
    };
  }
296338
public static <T> T median(final T[] a, Comparator<? super T> cmp) {
        N.checkArgNotNullOrEmpty(a, "The spcified array 'a' can not be null or empty");

        return median(a, 0, a.length, cmp);
    }
684092
function median(array) {
  var length = array.length;

  if (length === 0) {
    throw new RangeError("Error");
  }

  array.sort(function(a, b) {
    return a - b;
  });

  var middle = Math.floor(length / 2);

  return length % 2 ? array[middle] : (array[middle] + array[middle - 1]) / 2;
}
869983
public static <T extends Comparable<? super T>> T median(final Collection<? extends T> c) {
        N.checkArgNotNullOrEmpty(c, "The spcified collection 'c' can not be null or empty");

        return median(c, 0, c.size());
    }
1140394
public static <T extends Comparable<? super T>> Collector<T, ?, Optional<T>> max() {
        return maxBy(t -> t, naturalOrder());
    }