def compute_sign(permutation):
    """Compute sign by sorting."""
    sign = 1
    n = len(permutation)
    p = [p for p in permutation]
    for i in range(n - 1):
        for j in range(n - 1):
            if p[j] > p[j + 1]:
                p[j], p[j + 1] = p[j + 1], p[j]
                sign = -sign
            elif p[j] == p[j + 1]:
                return 0
    return sign
