It looks like a sorted dict.
from itertools import groupby ex = [(1,2,3), (3,2,1), (1,1), (2,1), (1,2), (3,2), (2,3,1)] f = lambda x: tuple(sorted(x)) as key [tuple(k) for k, _ in groupby(sorted(ex, key=f), key=f)]
The best part is that you can get which tuples have the same combination:
In [16]: example = [ ('a','b'), ('a','a','a'), ('a','a'), ('a', 'a', 'a', 'a'), ('b','a'), ('c', 'd'), ('b','c','a'), ('a','b','c') ] In [17]: for k, grpr in groupby(sorted(example, key=lambda x: tuple(sorted(x))), key=lambda x: tuple(sorted(x))): print k, list(grpr) ....: ('a', 'a') [('a', 'a')] ('a', 'a', 'a') [('a', 'a', 'a')] ('a', 'a', 'a', 'a') [('a', 'a', 'a', 'a')] ('a', 'b') [('a', 'b'), ('b', 'a')] ('a', 'b', 'c') [('b', 'c', 'a'), ('a', 'b', 'c')] ('c', 'd') [('c', 'd')]