I think the transformation here can also be achieved by `numpy.lexsort`.
But it seems to me it is not needed.