I have a very odd issue when trying to sort my permutations.
As I have seen before on SO, using a set to sort and distinct a list is the way to go, but for one particular list, this seems not to work. We can take this for example
>>> set([2,1])
{1, 2}
>>> set([1,2,1])
{1, 2}
>>> set([513, 135, 531, 153, 315, 351])
{513, 135, 531, 153, 315, 351}
>>>
Anyone who can give me any guidance?
Sets are by definition an unordered collection.
To get a sorted collection from a set use
sorted(set([2,1]))
https://docs.python.org/2/library/sets.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With