Feature request: sorting a list slice

George Sakkis george.sakkis at gmail.com
Thu May 18 13:27:48 EDT 2006


It would be useful if list.sort() accepted two more optional
parameters, start and stop, so that you can sort a slice in place. In
other words,

x = range(1000000)
x.sort(start=3, stop=-1)

would be equivalent to

x[3:-1] = sorted(x[3:-1])

but more efficient and without repeating the slice twice. If it's not
too late for feature additions, I'd love to see this in 2.5.


George




More information about the Python-list mailing list