Computer Science

Running the code sorted(mydictionary, reverse = True) on a dictionary named mydictionary will return results sorted in what order?

  1. Ascending order (A-Z), by key
  2. Ascending order (A-Z), by value
  3. Descending order (Z-A), by key
  4. Descending order (Z-A), by value

Python Dictionaries

1 Like

Answer

Descending order (Z-A), by key

Reason — The sorted() function returns a sorted list of dictionary keys. By default, the sort order is ascending. To sort the keys in descending order, the reverse parameter must be set to true as an optional argument (sorted(my_dictionary, reverse = True)).

Answered By

1 Like


Related Questions