I have a custom list like this :
mylist1= [-2,0,1,1.5,2,3,6,8,5,'a','-%3','A',True,False,list(),tuple(),dict()]
Here I have most of the datatypes in this list,so I just tried to sort them and see how it sorts all them.
And It gave me output like this:
print sorted(mylist1)
[-2, 0, False, 1, True, 1.5, 2, 3, 5, 6, 8, {}, [], '-%3', 'A', 'a', ()]
Here we can see {} is placed before [] and () at the most end.
All I searched and got __cmp__ is running inside this mergesort.
More info
I have two questions:
Question1:
I just want to know how this precedence of values with the different datatypes is defined in python
Question2:
If I include set() in above mylist, it won't run this sort. why so? it is showing TypeError: can only compare to a set