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.


sorted() function sorts in ascending order by default.

lst2 = sorted(lst1)

Exercise 15-b

Using sorted() function, sort the list from a to z.


sorted() function sorts in ascending order (also a to z in strings) by default.

lst2 = sorted(lst1)