possible duplicate:
python: sort part of list, in place
i want implement decision tree algorithm, , implementation calls sorting table in order attribute attribute, in place.
here gist of it: choose attribute, sort on it. entries in table share attribute can thought of list, because permuting within them not modify attribute.
so then, how can sort relevant subportion? need write own wrapper around list specified base , length?
this sort-of inplace. does require temporary storage sorted part
>>> a=range(20,0,-1) >>> [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1] >>> a[10:15]=sorted(a[10:15]) >>> [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 6, 7, 8, 9, 10, 5, 4, 3, 2, 1] >>>
Comments
Post a Comment