我有两个列表。
第一个列表已经按照某些其他标准排序,越早在列表中的位置越好。
第二个列表是允许值的列表:
第一个列表已经按照某些其他标准排序,越早在列表中的位置越好。
sortedList = ['200', '050', '202', '203', '206', '205', '049', '047', '042', '041', '043', '044', '046', '045', '210', '211', '306', '302', '308', '309', '311', '310', '221', '220', '213', '212']
第二个列表是允许值的列表:
allowedList = ['001','002','003','004','005','006','007','008','009','010','203','204','205','206','207','212','213','215','216']
我想选择在allowedList中存在的最高排序值,但是我只能想到一些愚蠢的方法。比如:
import numpy as np
temp = []
for x in allowedList:
temp.append(sortedList.index(x))
np.min(temp)
一定有比这更好的方法。你有什么想法吗?