compareWith method

int compareWith(
  1. Iterable<T> other
)

Compares two Iterables.

Similar to String.compareTo.

Implementation

int compareWith(Iterable<T> other) {
  if (identical(this, other)) return 0;

  final len1 = length;
  final len2 = other.length;
  final lim = math.min(len1, len2);

  var k = 0;
  while (k < lim) {
    var c1 = elementAt(k);
    var c2 = other.elementAt(k);

    var cmp = c1.compareTo(c2);

    if (cmp != 0) {
      return cmp;
    }
    k++;
  }
  return len1 - len2;
}