如果我有子列表A:['E','C','W'],根据主列表M的顺序对子列表进行排序的最pythonic方法是什么:['C','B','W ','E','K']
我的解决方案似乎相当初级。我很好奇是否有更“pythonic”的方式来获得相同的结果。
ORDER = ['C','B','W','E','K']
possibilities = ['E','C', 'W']
possibilities_in_order = []
for x in ORDER:
if x in possibilities: possibilities_in_order.append(x)