ts-iterable-functions
    Preparing search index...

    Function _thenByDescending

    • Adds a secondary descending sort key to an OrderedIterable.

      Type Parameters

      • T

        Element type contained in the ordered iterable.

      • TCmp

        Key type produced by the selector.

      Parameters

      Returns OrderedIterable<T>

      An OrderedIterable extended with the extra descending key.

      Error Rethrows any error thrown by selector.

      const items = [
      { category: "fruit", name: "banana" },
      { category: "vegetable", name: "okra" },
      { category: "fruit", name: "apple" },
      ];
      const ordered = _orderBy(items, (item) => item.category);
      const sorted = [..._thenByDescending(ordered, (item) => item.name)];
      console.log(sorted);
      // [
      // { category: "fruit", name: "banana" },
      // { category: "fruit", name: "apple" },
      // { category: "vegetable", name: "okra" },
      // ]

      or using the curried version:

      const sorted = [
      ...pipeInto(
      [
      { category: "fruit", name: "banana" },
      { category: "vegetable", name: "okra" },
      { category: "fruit", name: "apple" },
      ],
      orderBy((item) => item.category),
      thenByDescending((item) => item.name)
      ),
      ];
      console.log(sorted);
      // [
      // { category: "fruit", name: "banana" },
      // { category: "fruit", name: "apple" },
      // { category: "vegetable", name: "okra" },
      // ]