I have a list which contains lists. I am trying to remove any duplicates of lists which may share the same items within the list but in a different order.
for example if I have this
nestedlist=[[1,2,3,4],[4,3,2,1],[1,5,8,7]]
I would like a function that returns something like:
[[1,2,3,4],[1,5,8,7]]
>Solution :
Sort the list after acessing sub list and compare accordingly.
new=[]
nestedlist=[[1,2,3,4],[4,3,2,1],[1,5,8,7]]
for i in nestedlist:
if sorted(i) not in new:
new.append(i)
print(new)
Gives #
[[1, 2, 3, 4], [1, 5, 8, 7]]