def sort_nested_dict(value):
 result = OrderedDict()
 for (key, value) in sorted(value.items(), key=sort_key_by_numeric_other):
  if isinstance(value, (dict, OrderedDict)):
   result[key] = sort_nested_dict(value)
  else:
   result[key] = value
 return result

def sort_nested_dict ( value ) : result = OrderedDict ( ) for ( key , value ) in sorted ( value . items ( ) , key = sort_key_by_numeric_other ) : if isinstance ( value , ( dict , OrderedDict ) ) : result [ key ] = sort_nested_dict ( value ) else : result [ key ] = value return result
recursively sort a nested dict .