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/2003-October/038764.html below:

[Python-Dev] decorate-sort-undecorate

[Python-Dev] decorate-sort-undecorate [Python-Dev] decorate-sort-undecorateMark Russell marktrussell at btopenworld.com
Wed Oct 15 14:42:47 EDT 2003
On Wed, 2003-10-15 at 18:52, Guido van Rossum wrote:
> > While we're hacking on [].sort(), how horrible would it be if we
> > modified it to return self instead of None?
> 
> -1000.  This is non-negotiable.

I have a trivial wrapper function sortcopy() in my
I-wish-these-were-builtins module:

def sortcopy(vals, cmpfunc=None):
    """Non in-place wrapper for list.sort()."""
    copy = list(vals)
    copy.sort(cmpfunc)
    return copy

I use this more often than list.sort(), because most of the time
performance and memory use is not an issue and code using the in-place
version is irritatingly verbose.  Maybe this is worth adding as a
builtin, to satisfy the people that want a non in-place sort.

Mark Russell

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