In Python 2.x, items of dissimilar types which are not directly comparable are compared using the name of their types. So all integers are less than all lists, because "int"
is less than "list"
. For the same reason all str
s are greater than all int
s and float
s.
This unintuitive behavior (which I assume was introduced so that items of like type sort together in a heterogeneous list) was removed in Python 3, which raises an exception for these comparisons.