I have searched and haven't quite found the same question as mine. I want to remove duplicates from a list of lists in python; however, I don't care what order the values are in the list. They way I am doing it currently is too time-consuming.
What I want to do:
A = [[1,2,3] , [2,3,4] , [3,4,5] , [3,2,4]]
I want to search through A and remove all duplicates. The duplicates here would be [2,3,4] and [3,2,4]. This would reduce down to:
smaller_A = [[1,2,3] , [2,3,4], [3,4,5]]
How I am currently doing it:
todelete = []
for i in range(len(A)):
for j in range(i+1,len(A)):
if set(A[i]) == set(A[j]):
todelete.append(j)
todelete = sorted(set(todelete))
smaller_A= [A[i] for i in range(len(A)) if i not in todelete]
Again, this works, but it is very time consuming when my lists are large. Any ideas? Thanks!