Make sure the JSON is written in canonical form

This uses the `sort_keys` functionality of python's JSON module
to make sure the settings file doesn't change when the settings don't change.