def ordered_obj(obj):
 if isinstance(obj, dict):
  return sorted(((k, ordered_obj(v)) for (k, v) in obj.items()))
 if isinstance(obj, list):
  return sorted((ordered_obj(x) for x in obj))
 else:
  return obj

def ordered_obj ( obj ) : if isinstance ( obj , dict ) : return sorted ( ( ( k , ordered_obj ( v ) ) for ( k , v ) in obj . items ( ) ) ) if isinstance ( obj , list ) : return sorted ( ( ordered_obj ( x ) for x in obj ) ) else : return obj
order object for comparison purposes .