[Python-ideas] Sort statement

David Pokorny dbpokorny at gmail.com
Sat Jun 14 06:52:30 CEST 2008

In the spirit of going in the reverse direction of turning print into
a function, what does python-ideas think of the sort statement?

numlist = [2,5,4]
sort numlist
sort numlist asc # borrowed from SQL ORDER BY statement
sort numlist desc
sort by employee.last_name for employee in employee_list # this uses key sorting

The main advantage is that it is impossible to make this mistake:

x = y.sort()

when you really mean

x = sorted(y)


More information about the Python-ideas mailing list