如何从一个元组列表中删除第二个元素是重复的元素?
例如,我有一个按照第一个元素排序的列表,看起来像这样:
alist = [(0.7897897,'this is a foo bar sentence'),
(0.653234, 'this is a foo bar sentence'),
(0.353234, 'this is a foo bar sentence'),
(0.325345, 'this is not really a foo bar'),
(0.323234, 'this is a foo bar sentence'),]
期望的输出是保留第一个元素最大值的元组,应为:
alist = [(0.7897897,'this is a foo bar sentence'),
(0.325345, 'this is not really a foo bar')]