Sorted Dictionary Keys

  • Share this:

Code introduction


This function takes a dictionary object as input and returns a list containing all the keys of the dictionary. The keys in the list are sorted in alphabetical order.


Technology Stack : Built-in type - Dictionary

Code Type : Function

Code Difficulty : Beginner


                
                    
def aord_keys(dict_obj):
    """
    返回字典中所有键的列表,并按字母顺序排序。

    :param dict_obj: 输入的字典对象
    :return: 排序后的键列表
    """
    return sorted(dict_obj.keys())