According to Quentin Spencer <address@hidden> (on 09/15/04):
Output from MATLAB R14:
x = [Inf, NaN, -Inf, 3, 2, 1];
[a, ai] = sort (x, 'ascend')
a =
-Inf 1 2 3 Inf NaN
ai =
3 6 5 4 1 2
[a, ai] = sort (x, 'descend')
a =
NaN Inf 3 2 1 -Inf
ai =
2 1 4 5 6 3
Now this isn't what I would have expected. I'd assumed that the NaN's
were always sorted to the end. It seems that matlab always does an
ascending sort and then a flip(lr|ud) or whatever... It might in fact
be faster this way, but the advantage of always sorting the NaN's
to the end would be that it is easier to drop them...
For compatiability we shoudl probably do the same thing...