In python you can produce JSON with keys in sorted order by doing
import json print json.dumps({\'4\': 5, \'6\': 7}, sort_keys=True, indent=4, separators=(\'
The json package always orders keys when marshalling. Specifically:
Maps have their keys sorted lexicographically
Structs keys are marshalled in the order defined in the struct
The implementation lives here ATM: