Sorting Dictionary Keys in Ascending Order

  • Share this:

Code introduction


This function takes a dictionary as an argument and returns a list of keys sorted in ascending order.


Technology Stack : Dictionary (dict)

Code Type : Function

Code Difficulty : Intermediate


                
                    
def aord_keys(d):
    """
    Return a sorted list of keys from a dictionary.

    :param d: The dictionary to sort the keys from.
    :return: A list of keys sorted in ascending order.
    """
    return sorted(d.keys())