Finding the intersection in two lists of tuples regardless of tuple order
问题 I have two lists of tuples listA = [('1','2'),('3','4'),('5','6')] listB = [('2','1'),('7','8')] I want to find the intersection of them even if the order of the tuple in the second list is different. So, for the example above: intersection = [('1','2')] the intersection should return the tuple above though it is not in the same order in listB How can I do that in python the most efficient way? because each of my list has around 2000 tuples. 回答1: >>> set(map(frozenset, listA)) & set(map