Write a function that returns a dictionary sorted descending by its values


Topic: Write a function that returns a dictionary sorted descending by its values

Solution

def descending_dict_valuesort(d:dict):
    return {key: val for key, val in sorted(d.items(), reverse=True, key = lambda ele: ele[1])}



List all Python Programs