New submission from guillard <yoann.reservati...@gmail.com>:
If the dict included both str and int keys, sorted returns this error : TypeError: '<' not supported between instances of 'int' and 'str' It is a little bit problematic when used with default library behavior, as jsonify in Flask. possible solution : try: items = sorted(dct.items()) except(TypeError): items = sorted(dct.items(), key=lambda kv: str(kv[0])) ---------- files: json_bug_exemple.py messages: 351268 nosy: yoann934 priority: normal severity: normal status: open title: JSON sorting type error type: behavior versions: Python 3.7 Added file: https://bugs.python.org/file48596/json_bug_exemple.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38046> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com