[Patches] [ python-Patches-661092 ] list.sort cmpfunc default
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 02 Jan 2003 06:28:39 -0800
Patches item #661092, was opened at 2003-01-02 08:28
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=661092&group_id=5470
Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Tim Peters (tim_one)
Summary: list.sort cmpfunc default
Initial Comment:
It surprised me today when I saw a functional sort written like this:
def sort(sequence, cmpfunc=None):
sorted = list(sequence)
if cmpfunc is None:
sorted.sort()
else:
sorted.sort(cmpfunc)
return sorted
If [].sort() was written in Python its function signature would be declared as above (obviously the body would be different), and the above functional sort could be written as:
def sort(sequence, cmpfunc=None):
sorted = list(sequence)
sorted.sort(cmpfunc)
return sorted
The attached patch supports calling [].sort() with an explicit argument of None. (No doc change yet. If you approve, I will make that mod.)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=661092&group_id=5470