我想根据另一个元组列表对列表中的键进行排序。基于元组列表对元组列表进行排序 - Python
说我有以下几点:
list1 = [(5, 'something'),(2,'bobby'),(9,'suzy'),(6,'crab')]
list2 = [('something','othervalues'),('suzy','stuff'),('bobby','otherthings')]
而从这个我会收到列表1中的每个元组的第一个元素在输出soring。
sorted = [('suzy','stuff'),('something','othervalues'),('bobby','otherthings') ]
因此,本质上它执行一个交集,然后通过list1的元组中的第一个元素对剩余值进行排序。
我不知道该怎么做,所以任何帮助都会很棒。