0 out of 464 challenges solved
Write a function `sort_dict_by_value` that takes a dictionary as input and returns a list of tuples, where each tuple contains a key-value pair from the dictionary, sorted in descending order by the values. #### Example Usage ```python [main.nopy] result = sort_dict_by_value({'Math': 81, 'Physics': 83, 'Chemistry': 87}) print(result) # Output: [('Chemistry', 87), ('Physics', 83), ('Math', 81)] result = sort_dict_by_value({'A': 1, 'B': 3, 'C': 2}) print(result) # Output: [('B', 3), ('C', 2), ('A', 1)] ```
from typing import Dict, List, Tuple def sort_dict_by_value(input_dict: Dict[str, int]) -> List[Tuple[str, int]]: """ Sorts a dictionary by its values in descending order. Args: input_dict (Dict[str, int]): The dictionary to sort. Returns: List[Tuple[str, int]]: A list of tuples sorted by values in descending order. """ # Your code here pass