@alextheman/utility - v5.34.0
    Preparing search index...

    Function sortBy

    • Provides a function to pass to the sort or toSorted methods on arrays, which will allow those methods to sort the items by the chosen value in the chosen direction.

      Type Parameters

      • ItemType

        The type of each array item.

      • SortValue extends string | number | VersionNumber | Date | Decimal

        The type of the value to sort by.

      Parameters

      • selector: (item: ItemType) => SortValue

        A function that takes the item and returns the value to sort by.

      • direction: SortDirection = "asc"

        The sort direction.

      Returns SortFunction<ItemType>

      A function to pass into the .sort() or .toSorted() methods on arrays.