compareTo method

  1. @override
int compareTo(
  1. Pair<T> other
)
override

Compare this with other if T implements Comparable.

Implementation

@override
int compareTo(Pair<T> other) {
  var a = this.a;
  if (a is Comparable) {
    var cmp = a.compareTo(other.a);
    if (cmp == 0) {
      var b = this.b as Comparable;
      cmp = b.compareTo(other.b);
    }
    return cmp;
  }

  throw UnimplementedError("Type `$T` does NOT implement `Comparable`");
}