Options
All
  • Public
  • Public/Protected
  • All
Menu

Module function/comparator

Index

References

Functions

References

Renames and re-exports comparator

Functions

  • comparator<T>(pred: Pred2<T, T>): (x: T, y: T) => 0 | 1 | -1
  • Makes a comparator function out of a function that reports whether the first element is less than the second.

    example
     var byAge = comparator((a, b) => a.age < b.age);
    var people = [
    // ...
    ];
    var peopleByIncreasingAge = sort(byAge, people);

    Type parameters

    • T

    Parameters

    • pred: Pred2<T, T>

      A predicate function of arity two which will return true if the first argument is less than the second, false otherwise

    Returns (x: T, y: T) => 0 | 1 | -1

    A Function :: a -> b -> Int that returns -1 if a < b, 1 if b < a, otherwise 0

      • (x: T, y: T): 0 | 1 | -1
      • Parameters

        • x: T
        • y: T

        Returns 0 | 1 | -1

Generated using TypeDoc