귀하의 하위 목록이 모두 같은 세 가지 항목의 구조를 가지고 있다고 가정은, 이후 당신은 항상 할 수있는, 사용하기 매우 합리적인 데이터 구조처럼 보인다 색인 [0], [1] 및 [2]로 이미지 객체, 소스 및 버전에 액세스합니다.
이 코드는 소스를 사전의 키가되게하고 하위 목록은 해당 키의 값을 만듭니다.
bigList = [['foo', 1, 2], ['asdf', 2, 5], ['bar', 1, 3]]
uniqueSources = {}
for sublist in bigList:
currentSource = sublist[1]
if currentSource in uniqueSources:
if sublist[2] > uniqueSources[currentSource][2]:
uniqueSources[currentSource] = sublist
else: uniqueSources[currentSource] = sublist
dupesRemoved = list(uniqueSources.values())
print(dupesRemoved)