compareBytes static method

int compareBytes(
  1. List<int> a,
  2. List<int> b
)

Compare two Uint8Lists lexicographically.

Implementation

static int compareBytes(List<int> a, List<int> b) {
  final length = a.length < b.length ? a.length : b.length;

  for (var i = 0; i < length; i++) {
    if (a[i] < b[i]) {
      return -1;
    } else if (a[i] > b[i]) {
      return 1;
    }
  }

  if (a.length < b.length) {
    return -1;
  } else if (a.length > b.length) {
    return 1;
  }

  return 0;
}