Once an iterator’s Sequences of the same type also support comparisons.
In particular, tuples and lists are compared lexicographically by comparing corresponding elements.
The exception when comparing a complex number with another built-in numeric type, when the objects are of different types that cannot be compared, or in other cases where there is no defined ordering.
Non-identical instances of a class normally compare as non-equal unless the class defines the that hold floating-point numbers with user-definable precision.) Numbers are created by numeric literals or as the result of built-in functions and operators.
A sort is stable if it guarantees not to change the relative order of elements that compare equal — this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade).
CPython implementation detail: While a list is being sorted, the effect of attempting to mutate, or even inspect, the list is undefined.
This syntax is similar to the syntax specified in section 188.8.131.52 of the C99 standard, and also to the syntax used in Java 1.5 onwards.
The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions. The methods that add, subtract, or rearrange their members in place, and don’t return a specific item, never return the collection instance itself but Objects of different types, except different numeric types, never compare equal.
Furthermore, some types (for example, function objects) support only a degenerate notion of comparison where any two objects of that type are unequal.
This can be useful when debugging, and in numerical work.
is a decimal integer with an optional leading sign.
All numeric types (except complex) support the following operations, sorted by ascending priority (all numeric operations have a higher priority than comparison operations): Bitwise operations only make sense for integers.