In-place sort of sublist
list, python, slice, sorting, view
Solution
If `numpy` is an option:
>>> x = np.array([1, 8, 90, 30, 5])
>>> x[2:].sort()
>>> x
array([ 1, 8, 5, 30, 90])
`numpy` array slices are always views of the original array.
Problem
Is it possible? Obviously `x[1:-1].sort()` doesn't work because the slice is a copy. Current workaround: ``` >>> x = [4, 3, 1, 2, 5] >>> s = slice(1, -1) >>> x[s] = sorted(x[s]) >>> x [4, 1, 2, 3, 5] ``` Can I somehow get a view on a python list?