def reorder_simd_loops(loops):
    """Reorder the simd loops for pruning.

    The input loops contains a list of candidate loops.
    For each candidate loop, it is in the format of [1, 1, X].
    We will sort the loops based on the non-one element in descending order.

    Parameters
    ----------
    loops: list
        A list containing all candidate SIMD loops to be evaluated.
    """
    # Find the position of the non-one element.
    pos = -1
    for loop in loops:
        for i in range(len(loop)):
            if loop[i] != 1:
                pos = i
                break
        if pos != -1:
            break

    if pos == -1:
        # All the loops are ones.
        return loops

    loops.sort(key=lambda x: x[pos], reverse=True)
    return loops