Develop a NumPy program to sort the student id with increasing height of the students from given students id and height. Print the integer indices that describes the sort order by multiple columns and the sorted data.
import numpy as np
students = np.array([[1,2], [2,3], [3,4], [5,6]])
print("Sort #2")
students[students[:,1].argsort()[::-1]]
for i, j in students:
print(i, j)
print("\nSort #1")
students[(-students[:,1]).argsort()]
for i, j in students:
print(i, j)
Comments
Leave a comment