Function orderByDescending

  • Sorts the elements of a sequence in descending order.

    Example

    const items = [{ id: 1 }, { id: 3 }, { id: 2 }];
    const ordered = orderByDescending(items, x => x.id).toArray(); // Will be [{ id: 3 }, { id: 2 }, { id: 1 }]

    Typeparam

    TSource The type of the source iterable.

    Typeparam

    TKey The type of the key returned by keySelector.

    Returns

    An IOrderedEnumerable whose elements are sorted according to a key.

    Type Parameters

    • TSource

    • TKey

    Parameters

    • src: Iterable<TSource>

      The source iterable.

    • keySelector: ((item: TSource) => TKey)

      A function to extract the key for each element.

        • (item: TSource): TKey
        • Parameters

          • item: TSource

          Returns TKey

    Returns IOrderedEnumerable<TSource>

  • Sorts the elements of a sequence in descending order.

    Example

    const items = [{ id: 1 }, { id: 3 }, { id: 2 }];
    const ordered = orderByDescending(items, x => x.id).toArray(); // Will be [{ id: 3 }, { id: 2 }, { id: 1 }]

    Typeparam

    TSource The type of the source iterable.

    Typeparam

    TKey The type of the key returned by keySelector.

    Returns

    An IOrderedEnumerable whose elements are sorted according to a key.

    Type Parameters

    • TSource

    • TKey

    Parameters

    • src: Iterable<TSource>

      The source iterable.

    • keySelector: ((item: TSource) => TKey)

      A function to extract the key for each element.

        • (item: TSource): TKey
        • Parameters

          • item: TSource

          Returns TKey

    • comparer: Comparer<TKey>

      An Comparer to compare keys.

    Returns IOrderedEnumerable<TSource>

Generated using TypeDoc