!7 static int compareUtf8(byte[] left, byte[] right) { int n = min(left.length, right.length); for (int i = 0; i < n; i++) { int a = left[i] & 0xff; int b = right[i] & 0xff; if (a != b) ret a-b; } ret left.length - right.length; } p { bool ok = true; repeat 10000 { //S a = aGlobalID(), b = aGlobalID(); //S a = totallyRandomChars(10), b = totallyRandomChars(10); S a = fairlyRandomChars(10), b = fairlyRandomChars(10); try { assertEquals(sign(a.compareTo(b)), sign(compareUtf8(toUtf8(a), toUtf8(b)))); } catch print short e { print(toHex(toUtf8(a)) + " " + toHex(toUtf8(b))); ok = false; } } if (ok) print("OK!"); }