[New-bugs-announce] [issue29754] sorted ignores reverse=True when sorting produces same list
Tomas Dabašinskas
report at bugs.python.org
Wed Mar 8 00:32:52 EST 2017
New submission from Tomas Dabašinskas:
sorted ignores reverse=True when sorting produces same list, I was expecting reverse regardless of the sorting outcome.
Python 3.5.2 (default, Jul 17 2016, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> data = [{'name': 'first', 'weight': 1},{'name': 'second', 'weight': 1},{'name': 'third', 'weight': 1}, {'name': 'fourth', 'weight': 1}]
>>> sorted(data, key=lambda x: x['weight'], reverse=True)
[{'name': 'first', 'weight': 1}, {'name': 'second', 'weight': 1}, {'name': 'third', 'weight': 1}, {'name': 'fourth', 'weight': 1}]
>>> sorted(data, key=lambda x: x['weight'], reverse=True) == sorted(data, key=lambda x: x['weight']).reverse()
False
Thanks!
----------
components: Library (Lib)
messages: 289202
nosy: Tomas Dabašinskas
priority: normal
severity: normal
status: open
title: sorted ignores reverse=True when sorting produces same list
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29754>
_______________________________________
More information about the New-bugs-announce
mailing list