@Override
    public int compareTo(BString other)
    {
        // same object
        if (other == this) return 0;

        int p = start;
        int pOther = other.start;

        while (true) {
            // same length, all bytes matched
            if (p == end && pOther == other.end) return 0;

            // a bit unusual ordering here; of two strings where one is the prefix of the other,
            // the longest comes first
            if (p == end) return +1;
            if (pOther == other.end) return -1;

            int bComp = compareBytes(bytes[p], other.bytes[pOther]);

            if (bComp != 0) return bComp;

            ++p;
            ++pOther;
        }
    }