Python Sorted Exercises
Let’s check out some exercises that will help understand sorted() function better.
Exercise 15-a
Using sorted() function, sort the list in ascending order.
Exercise 15-b
Using sorted() function, sort the list from a to z.
Exercise 15-c
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)
Need More Exercises?
Check out Holy Python AI+ for amazing Python learning tools.
*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.
*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.
Umut Sagir
Finance & Data Science Professional,
Founder of HolyPython
Founder of HolyPython