Message289202
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! |
|
Date |
User |
Action |
Args |
2017-03-08 05:32:52 | Tomas Dabašinskas | set | recipients:
+ Tomas Dabašinskas |
2017-03-08 05:32:52 | Tomas Dabašinskas | set | messageid: <1488951172.21.0.568731538203.issue29754@psf.upfronthosting.co.za> |
2017-03-08 05:32:52 | Tomas Dabašinskas | link | issue29754 messages |
2017-03-08 05:32:51 | Tomas Dabašinskas | create | |
|