sorted or .sort() ?

Peter Bengtsson peterbe at gmail.com
Mon Jun 16 14:11:50 CEST 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