Confused about a list.sort()

David Goodger goodger at python.org
Wed Jan 28 03:50:04 CET 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