code: def sort_recursive(data):
      newdict = {}
      for i in data.items():
          if type(i[1]) is dict:
              newdict[i[0]] = sort_recursive(i[1])
          else:
              newdict[i[0]] = i[1]
      return OrderedDict(sorted(newdict.items(), key=lambda item: (compare_type(type(item[1])), item[0])))