public int compareTo(Object o){
    if(!(o instanceof ByteArray)) return this.toString().compareTo(o.toString());
    int thisbound=bytes.length;
    ByteArray cmp=(ByteArray)o;
    int obound=cmp.bytes.length;
    int bound=thisbound>obound?obound:thisbound;
    for(int i=0;i<bound;i++){
      if(bytes[i]==cmp.bytes[i]) continue;
      return (int)bytes[i]-(int)cmp.bytes[i];
    }
    return bound-obound;
  }