This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients josh.r, tanzer@swing.co.at
Date 2015-10-23.03:01:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1445569317.05.0.0955449357224.issue25457@psf.upfronthosting.co.za>
In-reply-to
Content
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]))))
History
Date User Action Args
2015-10-23 03:01:57josh.rsetrecipients: + josh.r, tanzer@swing.co.at
2015-10-23 03:01:57josh.rsetmessageid: <1445569317.05.0.0955449357224.issue25457@psf.upfronthosting.co.za>
2015-10-23 03:01:57josh.rlinkissue25457 messages
2015-10-23 03:01:56josh.rcreate