def move_1d(perm, from_start, from_end, insert_pos):
    """
    Move a block in a list.

    Parameters
    ----------
    perm : ndarray
        Permutation
    from_start : int
    from_end : int
    insert_pos : int

    Returns
    -------
    perm : ndarray
        The new permutation
    """
    if not (insert_pos < from_start or insert_pos > from_end):
        raise ValueError(
            'insert_pos={} needs to be smaller than from_start={} or greater than from_end={}'
            .format(insert_pos, from_start, from_end))
    if insert_pos > from_end:
        p_new = list(range(from_end + 1, insert_pos + 1)) + list(range(
            from_start, from_end + 1))
    else:
        p_new = list(range(from_start, from_end + 1)) + list(range(
            insert_pos, from_start))
    p_old = sorted(p_new)
    perm[p_old] = perm[p_new]
    return perm
