code: def sort_dict_by_key(obj):
      
      sort_func = lambda x: x[0]
      return OrderedDict(sorted(obj.items(), key=sort_func))
docs: Sort dict by its keys
  
      >>> sort_dict_by_key(dict(c=1, b=2, a=3, d=4))
      OrderedDict([('a', 3), ('b', 2), ('c', 1), ('d', 4)])