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


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

Solution

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



List all Python Programs