Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Searching
Sorting – sort()
Sorting – sorted()
12. sorted() in descending order
Sorting – reverse() and reversed()
Summary

Instruction

Fantastic! Just like sort(), sorted() can also sort elements in descending order using the optional reverse argument:

books = [
  'Sound of Steel',
  ...
]
sorted_books = sorted(books, reverse=True)

Note that we added an optional parameter to the invocation (reverse=True).

Exercise

Write a function named is_sorted(input_list). The function should return True if input_list is sorted in ascending or descending order. Otherwise, the function should return False.

Stuck? Here's a hint!

Create sorted copies of the list and compare them with the original list using the == operator.