Josh Rosenberg added the comment: Oops, minor flaw with that. It's str-ifying the tuples, not the keys, which could (in some cases) cause issues with keys whose reprs have different quoting. So you'd end up with lambdas. Boo. Anyway, corrected version (which would probably not be one-lined in real code):
json.dumps(collections.OrderedDict(sorted(mydict.items(), key=lambda x: str(x[0])))) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25457> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com