@mantlebee/ts-data
    Preparing search index...

    Function sortItems

    • Orders a list by its sorts, as a server would: by priority (the first sort wins, the next ones break its ties), stable (items equal for every sort keep their order), unset values first when ascending and last when descending. The comparables of every sort are computed once per item, through the comparer of the options (see toComparableValue), so strings are ordered ignoring the case unless options.caseSensitive. Values that are neither lower nor greater (mixed types, NaN) are equal. The list and its items are never mutated; the result is always a new array.

      Type Parameters

      • TItem = any

      Parameters

      Returns List<TItem>

      the ordered items; a copy of the list without sorts.

      const byName = sortItems(users, [
      { asc: true, field: "lastName" },
      { asc: true, field: "firstName" },
      ]);