sorted or .sort() ?

Peter Bengtsson peterbe at gmail.com
Mon Jun 16 08:11:50 EDT 2008


My poor understanding is that the difference between `sorted(somelist,
key=lambda x:...)` and `somelist.sort(lambda x,y...)` is that one
returns a new list and the other sorts in-place.

Does that mean that .sort() is more efficient and should be favored
when you can (i.e. when you don't mind changing the listish object)?



More information about the Python-list mailing list