https://en.wikipedia.org/wiki/Z-order_curve
def cmp_zorder(a, b):
j = 0
k = 0
x = 0
for k in range(dim):
y = a[k] ^ b[k]
if less_msb(x, y):
j = k
x = y
return a[j] - b[j]
def less_msb(x, y):
return x < y and x < (x ^ y)
It is also possible to compare floating point numbers using the same technique. The less_msb function is modified to first compare the exponents. Only when they are equal is the standard less_msb function used on the mantissas.[5]