Josh Rosenberg added the comment:

The Python 2 sort order is a result of the "arbitrary but consistent fallback 
comparison" (omitting details, it's comparing the names of the types), thus the 
"strange" sort order. Python 3 (justifiably) said that incomparable types 
should be incomparable rather than silently behaving in non-intuitive ways, 
hiding errors.

Python is being rather generous by allowing non-string keys, because the  JSON 
spec ( http://json.org/ ) only allows the keys ("names" in JSON parlance) to be 
strings. So you're already a bit in the weeds as far as compliant JSON goes if 
you have non-string keys.

Since mixed type keys lack meaningful sort order, I'm not sure it's wrong to 
reject attempts to sort them. Converting to string is as arbitrary and full of 
potential for silently incorrect comparisons as the Python 2 behavior, and 
reintroducing it seems like a bad idea.

----------
nosy: +josh.r

_______________________________________
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

Reply via email to