On 7 November 2017 at 03:27, Chris Jerdonek <chris.jerdo...@gmail.com> wrote: > On Mon, Nov 6, 2017 at 4:11 AM Nick Coghlan <ncogh...@gmail.com> wrote: >> Getting from the "Works on CPython 3.6+ but is technically >> non-portable" state to a fully portable correct implementation that >> ensures a particular key order in the JSON file thus currently >> requires the following changes: > > Nick, it seems like this is more complicated than it needs to be. You can > just pass sort_keys=True to json.dump() / json.dumps(). I use it for tests > and human-readability all the time.
sort_keys is only equivalent to order preservation if the key order you want *is* alphabetical order. While that's typically a good enough assumption for JSON, it's not the case for things like CSV column order, TOML or ini-file setting order, etc. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com