# compareTo method

1. @override

int compareTo(

1. Byte other

)
override

Compares this Byte with another Byte.

For single bytes, compares the byte values. For byte arrays, compares lexicographically.

Example:

    final a = Byte(10);
    final b = Byte(20);
    print(a.compareTo(b));  // -1 (a < b)

    final arr1 = Byte.fromList([1, 2, 3]);
    final arr2 = Byte.fromList([1, 2, 4]);
    print(arr1.compareTo(arr2));  // -1 (arr1 < arr2)

## Implementation

    @override
    int compareTo(Byte other) {
      // Compare lengths first for arrays
      if (_bytes.length != other._bytes.length) {
        return _bytes.length.compareTo(other._bytes.length);
      }

      // Compare element by element
      for (int i = 0; i < _bytes.length; i++) {
        final comparison = _bytes[i].compareTo(other._bytes[i]);
        if (comparison != 0) return comparison;
      }

      return 0; // Equal
    }