def order_recursive(data):
 if isinstance(data, dict):
  return collections.OrderedDict(sorted(((key, order_recursive(value)) for (key, value) in data.items()), key=(lambda item: item[0])))
 if isinstance(data, list):
  return [order_recursive(value) for value in data]
 return data

def order_recursive ( data ) : if isinstance ( data , dict ) : return collections . OrderedDict ( sorted ( ( ( key , order_recursive ( value ) ) for ( key , value ) in data . items ( ) ) , key = ( lambda item : item [ 0 ] ) ) ) if isinstance ( data , list ) : return [ order_recursive ( value ) for value in data ] return data
recursively sort keys of input data and all its nested dictionaries .