[Numpy-discussion] sort descending with NaNs

Fabrizio Pollastri f.pollastri at inrim.it
Thu Jan 27 11:50:49 EST 2011


when one has to find a given number of highest values in an array containing
NaNs, the sort function (always ascending) is uncomfortable.

Since numpy >= 1.4.0 NaNs are sorted to the end, so the searched values are just
before the first NaN in a unpredictable position and one has to do another
search for the first NaN position.

Sorting descending will solve the problem, but there is no option with numpy
sort. There is any other trick to avoid this second search?
Fabrizio Pollastri

More information about the NumPy-Discussion mailing list