whenEqual<A> static method

Order<A> whenEqual<A>(
  1. Order<A> first,
  2. Order<A> second
)

Returns a new Order<A> instance that first compares by the first Order instance and uses the second Order instance to "break ties".

That is, Order.whenEqual(x, y) creates an Order that first orders by x and then (if two elements are equal) falls back to y for the comparison.

Implementation

static Order<A> whenEqual<A>(Order<A> first, Order<A> second) =>
    _Order((x, y) {
      final ord = first.compare(x, y);
      return ord == 0 ? second.compare(x, y) : ord;
    });