Answer to Question #283353 in Python for ramk

Question #283353

 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.


1
Expert's answer
2021-12-29T13:37:22-0500
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS