def repos(ln, old_pos, new_pos):
    """
        Return a new list in which each item contains the index of the item
        in the old order.
        Uses the ranges approach (best for large arrays).
    """
    lb = min(new_pos, old_pos)
    ub = max(new_pos, old_pos)
    adj_range = []
    if new_pos < old_pos:
        adj_range.append(old_pos)
        adj_range += list(range(lb, ub))
    else:
        adj_range += list(range(lb + 1, ub + 1))
        adj_range.append(old_pos)
    return list(range(0, lb)) + adj_range + list(range(ub, ln - 1))
