How can I reorder a list in python according to another list, but without creating a new list, since it is linked by several objects?
This question and it's answers create new lists, so they don't apply.
How can I reorder a list in python according to another list, but without creating a new list, since it is linked by several objects?
This question and it's answers create new lists, so they don't apply.
You can create the list however you want, and then reassign the elements. For example:
X[:] = [x for (y,x) in sorted(zip(Y,X))]