How to reverse “reversed” duplicated tuples from a list in Python
Suppose I have a list of tuples: a = [(a,b), (a,b), (b,c), (b,a), (a,b), (c,b)] How can I find all the 'reversed' duplicated tuples like (a,b) and (b,a), (b,c) and (c,b); and change elements inside tuples in a consistent order, so it can become: a = [(a,b), (a,b), (b,c), (a,b), (a,b), (b,c)]
Short answer Convert tuples to list, sort the list, return it to a tuple type. def sort_tuples(alistoftuples): return [tuple(sorted(list(k))) for k in alistoftuples]
Running multiple Python scripts
programatically change matplotlib fill data
Python: include module into one *.py file
TypeError: can't multiply sequence by non-int of type 'tuple'
Assert that two dictionaries are almost equal
How to retry urllib2.urlopen n times
Python: Create a multidimensional array from a loop
MySQL SELECT: Find all languages by Unicode
how to write IS NOT for str.endswith in python [closed]
Python — Use of Numpy.mgrid and Numpy.reshape
How can I add more to a file when printing stdout to a file, instead of overwriting the file?
How do I create a custom window title bar using PyQt4?
Trouble printing all items from a list in python
Python datetime vs time
Error handling (dividing by zero) [duplicate]
Regex won't capture past \n