Sorting Dictionary by Key Alphabetically

  • Share this:

Code introduction


This function takes a dictionary as input and returns a new dictionary sorted by the alphabetical order of keys.


Technology Stack : Sorting

Code Type : Function

Code Difficulty :


                
                    
def aordict(data):
    """
    对字典数据按照键的字母顺序排序。
    """
    return dict(sorted(data.items()))                
              
Tags: