def _cmp_zorder(lhs, rhs) -> bool:
    """Used to check if two values are in correct z-curve order.
    Based on https://github.com/google/neuroglancer/issues/272#issuecomment-752212014

    Args:
        lhs: Left hand side to compare
        rhs: Right hand side to compare

    Returns:
        bool: True if in correct z order
    """
    def less_msb(x: int, y: int) -> bool:
        return x < y and x < (x ^ y)

    # Assume lhs and rhs array-like objects of indices.
    assert len(lhs) == len(rhs)
    # Will contain the most significant dimension.
    msd = 2
    # Loop over the other dimensions.
    for dim in [1, 0]:
        # Check if the current dimension is more significant
        # by comparing the most significant bits.
        if less_msb(lhs[msd] ^ rhs[msd], lhs[dim] ^ rhs[dim]):
            msd = dim
    return lhs[msd] - rhs[msd]