sorted(iterable, /, *, key=None, reverse=False) |
Returns test |
iterable | ?? |
key | ?? |
reverse | ?? |
REMARKS |
* No prefix required - Core * Return a new sorted list from the items in iterable. * Has two optional arguments which must be specified as keyword arguments. * key specifies a function of one argument that is used to extract a comparison key from each element in iterable (for example, key=str.lower). The default value is None (compare the elements directly). * reverse is a boolean value. If set to True, then the list elements are sorted as if each comparison were reversed. * Use functools.cmp_to_key() to convert an old-style cmp function to a key function. * The built-in sorted() function is guaranteed to be stable. 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). * The sort algorithm uses only < comparisons between items. While defining an __lt__() method will suffice for sorting, PEP 8 recommends that all six rich comparisons be implemented. This will help avoid bugs when using the same data with other ordering tools such as max() that rely on a different underlying method. Implementing all six comparisons also helps avoid confusion for mixed type comparisons which can call reflected the __gt__() method. |
??
© 2025 Better Solutions Limited. All Rights Reserved. © 2025 Better Solutions Limited Top