有没有python方法根据提供的新索引重新排序列表?

Hai*_*ang 4 python numpy

假设我有一个工作清单:['a','b','c']和索引列表[2,1,0],它会将工作清单更改为:['c','b','a "]

是否有任何python方法可以轻松完成此任务(工作列表也可能是一个numpy数组,因此更适合使用更具适应性的方法)?谢谢!

jfs*_*jfs 5

例:

>>> L = "abc"
>>> [L[i] for i in [2,1,0]]
['c', 'b', 'a']
Run Code Online (Sandbox Code Playgroud)