A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-June/054262.html below:

[Python-Dev] Propose to reject PEP 265 -- Sorting Dictionaries by Value

[Python-Dev] Propose to reject PEP 265 -- Sorting Dictionaries by ValueRaymond Hettinger raymond.hettinger at verizon.net
Fri Jun 17 03:03:57 CEST 2005
May I suggest rejecting PEP 265.

As of Py2.4, its use case is easily solved with:

>>> sorted(d.iteritems(), key=itemgetter(1), reverse=True)
[('b', 23), ('d', 17), ('c', 5), ('a', 2), ('e', 1)]

Further, Py2.5 offers a parallel solution to the more likely use case of
wanting the access only the largest counts:

>>> nlargest(2, d.iteritems(), itemgetter(1))
[('b', 23), ('d', 17)]


Raymond

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4