Removing permutations from a list of tuples

python, python-2.7

Solution

You could sort them and then remove duplicates with `set()`:

>>> set(tuple(sorted(l)) for l in a)
    set([(1, 2), (1, 3), (1, 4)])

Problem

Any help with this question is appreciated. I have a list of tuples ``` a = [(1,2), (2,1), (1,3), (1,4), (4,1)] ``` and I need to remove duplicates of a certain type: (1,2) and (2,1) are considered duplicates according to my definition. Required output ``` a = [(1,2), (1,3), (1,4)] ``` Thanks in advance

Original source