Function sorter

  • Array.prototype.sort()の引数に指定するソート条件です。

    ["aa", "bbb", "c"].sort(sorter(x => x.length, "desc"))
    // ["bbb", "aa", "c"]

    Type Parameters

    • T

    • U extends string | number

    Parameters

    • toOrdered: ((t) => U)
        • (t): U
        • Parameters

          • t: T

          Returns U

    • order: "asc" | "desc" = "asc"

    Returns ((a, b) => 1 | -1 | 0)

      • (a, b): 1 | -1 | 0
      • Parameters

        • a: T
        • b: T

        Returns 1 | -1 | 0

Generated using TypeDoc