Let’s check out some exercises that will help understand sorted() function better.
Using sorted() function, sort the list in ascending order.
Using sorted() function, sort the list from a to z.
Using sorted() function sort the list from z to a.
sorted() function sorts in ascending order (also a to z in strings) by default.
sorted() function sorts in ascending order (also a to z in strings) by default. If you’d like to reverse the sorting order you can simply set reverse parameter to True:
sorted(list, reverse=True)
lst2 = sorted(lst1, reverse = True)