Confused about a list.sort()

David Goodger goodger at python.org
Tue Jan 27 21:50:04 EST 2004


list.sort() sorts the list in-place; it doesn't return a new list.
Instead of "List1 = List1.sort()" just do "List1.sort()".

See the FAQ entry:
http://www.python.org/doc/faq/general.html#why-doesn-t-list-sort-return-the-sorted-list

-- David Goodger





More information about the Python-list mailing list