1

The numpy arrays symbols and ocurrence both have the same size/len.

bidimentional_array = np.array([symbols,occurrence])

What I want is, do a descending sort in ocurrence and make it so that symbols index will change in function of the sort. What's the most effective way?

1

1 Answer 1

1

Use np.argsort to obtain the sorting indices according to the second column and fancy indexing to obtain the sorted array:

bidimentional_array = bidimentional_array[np.argsort(bidimentional_array[:,1])]

To reverse the sorted array:

bidimentional_array = bidimentional_array[::-1]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.