SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Returns sorted numeric values in a range.

    Sorting requires materializing the full numeric population (O(n log n), one allocation). Unlike Aggregates, sorted views are not composable across sub-ranges.

    Covers the following Excel functions (all share one sort per coords per calc cycle):

    • LARGE, SMALL
    • MEDIAN, PERCENTILE, PERCENTILE.INC, PERCENTILE.EXC
    • QUARTILE, QUARTILE.INC, QUARTILE.EXC (q1 = k=0.25, q3 = k=0.75)
    • RANK, RANK.EQ, RANK.AVG
    • PERCENTRANK, PERCENTRANK.INC, PERCENTRANK.EXC
    • MATCH type 1/-1, VLOOKUP sorted, XLOOKUP (via findFloor/findCeiling)
    interface ISortedNumbers {
        findCeiling(x: number): number | null;
        findFloor(x: number): number | null;
        getLarge(k: number): number | null;
        getPercentile(k: number, exclusive?: boolean): number | null;
        getPercentRankOf(
            x: number,
            exclusive?: boolean,
            significance?: number,
        ): number | Known | null;
        getRankOf(
            x: number,
            descending?: boolean,
            average?: boolean,
        ): number | null;
        getSmall(k: number): number | null;
        getValues(): readonly number[];
    }
    Index
    • Binary search: returns the smallest value ≥ x, or null if none exists.

      Parameters

      • x: number

        The value to search for.

      Returns number | null

      Used by MATCH type -1 (sorted descending approximate match).

    • Binary search: returns the largest value ≤ x, or null if none exists.

      Parameters

      • x: number

        The value to search for.

      Returns number | null

      Used by MATCH type 1 and VLOOKUP sorted=true (approximate match, sorted ascending).

    • Returns the k-th largest numeric value (1-based).

      Parameters

      • k: number

        The rank of the value to return, where 1 is the largest value. A fractional rank becomes a 0-based index before it truncates — over five values k = 2.5 is the THIRD largest, not the second.

      Returns number | null

      null if k is out of range.

      Equivalent to Excel LARGE(array, k).

    • Returns the value at quantile k.

      Parameters

      • k: number

        Quantile in [0, 1] inclusive (or (0, 1) exclusive). Maps directly to Excel's k parameter. - k=0.5 → MEDIAN - k=0.25 → Q1 (QUARTILE quart=1) - k=0.75 → Q3 (QUARTILE quart=3)

      • Optionalexclusive: boolean

        If true, uses the exclusive interpolation formula (PERCENTILE.EXC / QUARTILE.EXC).

      Returns number | null

      The value at the specified quantile, or null if k is out of range or no numbers in range.

      Equivalent to Excel PERCENTILE.INC (exclusive=false) or PERCENTILE.EXC (exclusive=true).

    • Returns the fractional rank of value x as a value in [0, 1].

      Parameters

      • x: number

        The value whose percent rank to find. A value between two members is interpolated; one outside the population is not found.

      • Optionalexclusive: boolean

        If true, uses exclusive formula (0 and 1 are excluded).

      • Optionalsignificance: number

        Number of DECIMAL PLACES to TRUNCATE the result to — despite what Excel's own help calls the argument, it is not significant digits and it does not round. Truncated toward zero first (1.9 places means 1), and must be at least 1. Omit it for the exact untruncated rank, which is also the only form that cannot fail.

      Returns number | Known | null

      The percent rank of x; null if x is not found or there are no numbers in range.

    • Returns the rank of value x in the sorted population (1-based, descending by default).

      Parameters

      • x: number

        The value whose rank to find.

      • Optionaldescending: boolean

        If true (default), rank 1 = largest. If false, rank 1 = smallest.

      • Optionalaverage: boolean

        If true, tied values receive the average of their rank positions (RANK.AVG).

      Returns number | null

      The rank of x, or null if x is not found or no numbers in range.

      Equivalent to Excel RANK.EQ (average=false) or RANK.AVG (average=true).

    • Returns the k-th smallest numeric value (1-based).

      Parameters

      • k: number

        The rank of the value to return, where 1 is the smallest value. A fractional rank becomes a 0-based index before it truncates.

      Returns number | null

      null if k is out of range.

      Equivalent to Excel SMALL(array, k).

    • Returns all numeric values in the range, sorted ascending.

      Returns readonly number[]