diff --git a/pep-0000.txt b/pep-0000.txt index ec3663602..cb3e8fded 100644 --- a/pep-0000.txt +++ b/pep-0000.txt @@ -80,7 +80,6 @@ Index by Category S 256 Docstring Processing System Framework Goodger S 258 Docutils Design Specification Goodger SD 262 Database of Installed Python Packages Kuchling - S 265 Sorting Dictionaries by Value Griffin S 266 Optimizing Global Variable/Attribute Access Montanaro S 267 Optimized Access to Module Namespaces Hylton S 268 Extended HTTP functionality and WebDAV Stein @@ -200,6 +199,7 @@ Index by Category SR 242 Numeric Kinds Dubois SR 244 The `directive' Statement von Loewis SR 259 Omit printing newline after newline GvR + SR 265 Sorting Dictionaries by Value Griffin SD 269 Pgen Module for Python Riehl SR 270 uniq method for list objects Petrone SR 271 Prefixing sys.path by command line option Giacometti @@ -307,7 +307,7 @@ Numerical Index SD 262 Database of Installed Python Packages Kuchling SF 263 Defining Python Source Code Encodings Lemburg SF 264 Future statements in simulated shells Hudson - S 265 Sorting Dictionaries by Value Griffin + SR 265 Sorting Dictionaries by Value Griffin S 266 Optimizing Global Variable/Attribute Access Montanaro S 267 Optimized Access to Module Namespaces Hylton S 268 Extended HTTP functionality and WebDAV Stein diff --git a/pep-0265.txt b/pep-0265.txt index d3cd8f950..df6ee8ff8 100644 --- a/pep-0265.txt +++ b/pep-0265.txt @@ -2,7 +2,7 @@ PEP: 265 Title: Sorting Dictionaries by Value Version: $Revision$ Author: g2@iowegian.com (Grant Griffin) -Status: Draft +Status: Rejected Type: Standards Track Created: 8-Aug-2001 Python-Version: 2.2 @@ -17,6 +17,25 @@ Abstract both difficult for beginners to understand and cumbersome for all to implement. +BDFL Pronouncement + + This PEP is rejected because the need for it has been largely + fulfilled by Py2.4's sorted() builtin function: + + >>> sorted(d.iteritems(), key=itemgetter(1), reverse=True) + [('b', 23), ('d', 17), ('c', 5), ('a', 2), ('e', 1)] + + or for just the keys: + + sorted(d, key=d.__getitem__, reverse=True) + ['b', 'd', 'c', 'a', 'e'] + + Also, Python 2.5's heapq.nlargest() function addresses the common use + case of finding only a few of the highest valued items: + + >>> nlargest(2, d.iteritems(), itemgetter(1)) + [('b', 23), ('d', 17)] + Motivation