Sorting part of a list

Benji York benji at benjiyork.com
Fri Jun 24 08:20:35 EDT 2005


Fuzzyman wrote:
> a = ll[2:]
> a.sort()
> ll[2:] = a
> 
> To do a partial sort, in place, you'll have to subclass list 

Or be using 2.4:

 >>> ll = [3, 1, 4, 2]
 >>> ll[2:] = sorted(ll[2:])
 >>> ll
[3, 1, 2, 4]
--
Benji York



More information about the Python-list mailing list