public static <T, U> Collector<T, ?, Seq<T>> percentileAllBy(double percentile, Function<? super T, ? extends U> function, Comparator<? super U> comparator) {
        if (percentile < 0.0 || percentile > 1.0)
            throw new IllegalArgumentException("Percentile must be between 0.0 and 1.0");

        if (percentile == 0.0)
            return minAllBy(function, comparator);
        else if (percentile == 1.0)
            return maxAllBy(function, comparator);
        else
            return percentileCollector(
                function,
                comparator,
                Seq::empty,
                Seq::of,
                l -> {
                    int left = 0;
                    int right = percentileIndex(percentile, l.size());
                    int mid;

                    U value = l.get(right).v2;

                    // Search the first value equal to the value at the position of PERCENTILE by binary search
                    while (left < right) {
                        mid = left + (right - left) / 2;

                        if (comparator.compare(l.get(mid).v2, value) < 0)
                            left = mid + 1;
                        else
                            right = mid;
                    }

                    // We could use Seq.seq(l).skip(left).filter(<comparison>) to prevent the additional allocation
                    // but it is very likely that l is quite large and result is quite small. So let's not keep an
                    // unnecessary reference to a possibly large list.
                    List<T> result = new ArrayList<>();

                    for (; left < l.size() && comparator.compare(l.get(left).v2, value) == 0; left++)
                        result.add(l.get(left).v1);

                    return Seq.seq(result);
                }
            );
    }
Get a {@link Collector} that calculates the derived <code>PERCENTILE_DISC(percentile)</code> function given a specific ordering, producing multiple results.
jOOL-java-8/src/main/java/org/jooq/lambda/Agg.java