compareBytes function

int compareBytes(
  1. Uint8List a,
  2. Uint8List b
)

Compares two Uint8List bytes from the left-most to right-most byte. If all bytes are the same apart from one list being longer, the shortest list comes first.

Implementation

int compareBytes(Uint8List a, Uint8List b) {
  for (int i = 0; i < a.length && i < b.length; i++) {
    if (a[i] != b[i]) return a[i] - b[i];
  }
  return a.length - b.length;
}