Q:

Write a NumPy program to get the indices of the sorted elements of a given array

0

Write a NumPy program to get the indices of the sorted elements of a given array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
student_id = np.array([1023, 5202, 6230, 1671, 1682, 5241, 4532])
print("Original array:")
print(student_id)
i = np.argsort(student_id)
print("Indices of the sorted elements of a given array:")
print(i)

Sample Output:

Original array:
[1023 5202 6230 1671 1682 5241 4532]
Indices of the sorted elements of a given array:
[0 3 4 6 1 5 2]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now