• Performs a dense ranking on an array of items based on specified iteratees and orders. Each item in the array is assigned a rank, with identical items receiving the same rank. The rank is added to each item in a new field specified by the fieldName parameter.

    Type Parameters

    • T

      The type of the items in the array.

    • TRankField extends string = "rank"

      The type of the field name where the rank will be stored.

    Parameters

    • items: readonly T[] | T[]

      The array of items to be ranked.

    • iteratees: ((item) => unknown)[] | ((item) => unknown)

      An array of functions for producing the criteria by which to rank items.

    • Optional options: {
          fieldName?: TRankField;
          orders?: ("desc" | "asc")[];
          startingRank?: number;
      } = {}

      Optional settings for the ranking.

      • Optional fieldName?: TRankField

        The name of the field to store the rank in each item, defaults to "rank".

      • Optional orders?: ("desc" | "asc")[]

        The order to sort for each iteratee, defaults to ascending order.

      • Optional startingRank?: number

        The rank to start at, defaults to 1.

    Returns (T & {
        [K in TRankField]: number
    })[]

    • The array of items, each augmented with a rank field.

Generated using TypeDoc