@mirei/ts-collections
    Preparing search index...

    Function orderByDescending

    • Sorts the elements of a sequence in descending order by using a specified comparer.

      Type Parameters

      • TElement
      • TKey

      Parameters

      • source: Iterable<TElement>

        The source iterable.

      • keySelector: Selector<TElement, TKey>

        The key selector function that will be used for selecting the key for an element.

      • Optionalcomparator: OrderComparator<TKey, TKey>

        The comparator function that will be used for comparing two keys. If not specified, the default order comparison will be used.

      Returns IOrderedEnumerable<TElement>

      A new enumerable sequence whose elements are sorted in descending order.

      const people = [
      { name: 'Charlie', age: 22 },
      { name: 'Alice', age: 25 },
      { name: 'Bob', age: 30 },
      ];
      const sorted = orderByDescending(people, p => p.age).toArray();
      console.log(sorted);
      // [
      // { name: 'Bob', age: 30 },
      // { name: 'Alice', age: 25 },
      // { name: 'Charlie', age: 22 }
      // ]