import numpy as np vec = np.random.rand(5) #creating indices sorted_indices = vec.argsort() #sorting vector using indices sorted_vec = vec[sorted_indices] print(sorted_vec)