Loading section...
Sorting Lists
Concepts: pyListSort
The sort() Method Numbers are sorted from smallest to largest. Strings are sorted alphabetically based on Unicode code points, which means uppercase letters come before lowercase letters in a pure ASCII comparison. The original lists are modified directly. The sorted() Function The original list remains [3, 1, 4, 1, 5, 9, 2, 6] after calling sorted(). The sorted_copy is a new list containing the same values in sorted order. Notice that sorted() can work on strings too, returning a list of sorted characters. Sorting in Reverse Order Custom Sort Keys Sorting complex objects like dictionaries or tuples: