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.

classification
Title: Bug on sorted with count key
Type: behavior Stage: resolved
Components: Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Tamirys Pino, benjamin.peterson
Priority: normal Keywords:

Created on 2019-10-07 04:29 by Tamirys Pino, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg354063 - (view) Author: Tamirys Pino (Tamirys Pino) Date: 2019-10-07 04:29
>>> data=[2, 3, 2, 4, 5, 12, 2, 3, 3, 3, 12, 5]
>>> data
[2, 3, 2, 4, 5, 12, 2, 3, 3, 3, 12, 5]
>>> sorted(data)
[2, 2, 2, 3, 3, 3, 3, 4, 5, 5, 12, 12]
>>> sorted(data, key=data.count)
[4, 5, 12, 12, 5, 2, 2, 2, 3, 3, 3, 3]

[4, 5, 12, 12, 5, 2, 2, 2, 3, 3, 3, 3] should be [4, 5, 5, 12, 12, 2, 2, 2, 3, 3, 3, 3]
msg354064 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2019-10-07 04:32
5 and 12 both appear twice in the list, so as far as the key function is concerned, they're equal.
History
Date User Action Args
2022-04-11 14:59:21adminsetgithub: 82570
2019-10-07 04:32:59benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg354064

resolution: not a bug
stage: resolved
2019-10-07 04:29:16Tamirys Pinocreate