From what I understand of your question, it appears that you want to apply a permutation that you specify on a
list. This is done by specifying another
list (lets call it
p) that holds the indices of the elements of the original
list that should appear in the permuted
list. You then use
p to make a new
list by simply substituting the element at each position by that whose index is in that position in
def apply_permutation(lst, p):
return [lst[x] for x in p]
['d', 'c', 'a', 'b', 'e'].
This actually creates a new
list, but it can be trivially modified to permute the original “in place”.