Python doesn’t allow sorting of a dictionary. But while converting dictionary to a JSON, you can explicitly sort it so that the resulting JSON is sorted by keys. This is true for multi-dimentional dictionary. In case you need to sort a multi-dimentional JSON, convert it to dictionary and then dump it back to JSON with sorted flag.
ud = json.loads(js) print js # Unsorted JSON print ud # JSON to Dictionary (Unsorted) print json.dumps(ud, sort_keys=True) # This JSON will be sorted recursively