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?

Saullo G. P. Castro
  • 56,802
  • 26
  • 179
  • 234
Rayden
  • 160
  • 1
  • 9
  • possible duplicate of [Sort NumPy float array column by column](http://stackoverflow.com/questions/12496531/sort-numpy-float-array-column-by-column) – YXD Apr 18 '15 at 14:20

1 Answers1

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]
Saullo G. P. Castro
  • 56,802
  • 26
  • 179
  • 234