If all you care about is the order of the items on the most remote list (this is what everything offers me except the word "deep", this in itself makes me doubt what you had in mind), and you know that there will be no duplicates, you can use set
.
>>> larry = [(1,'a'), (2, 'b')] >>> moe = [(2, 'b'), (1, 'a')] >>> set(larry) == set(moe) True
If the case is as simple as these two sets, you can also use a dict
, which will be {1: 'a', 2: 'b'}
. This may or may not be a more convenient structure for you. In any case, comparing dict(larry) == dict(moe)
will do what you want.
If you care about duplicates, it will take a little more work, taking copies of the lists and pulling out the elements one by one until it fails, or is empty.
source share