Let\'s say we have a list:
a = [4, 8, 1, 7, 3, 0, 5, 2, 6, 9]
Now, a.sort() will sort the list in place. What if we want to sort only a
if a is a numpy array then to sort [i, j) range in-place, type:
a
numpy
[i, j)
a[i:j].sort()
Example:
>>> import numpy as np >>> a = np.array([4, 8, 1, 7, 3, 0, 5, 2, 6, 9]) >>> a[1:4].sort() >>> a array([4, 1, 7, 8, 3, 0, 5, 2, 6, 9])