From: A. M. A. <per...@gm...> - 2006-09-19 21:15:25
|
On 19/09/06, Tim Hochberg <tim...@ie...> wrote: > I'm not sure where the breakpoint is, but I was seeing failures for all > three sort types with N as high as 10000. I suspect that they're all > broken in the presence of NaNs. I further suspect you'd need some > punishingly slow n**2 algorithm to be robust in the presence of NaNs. Not at all. Just temporarily make NaNs compare greater than any other floating-point value and use quicksort (say). You can even do this for python lists without much trouble. That's actually a viable suggestion for numpy's sorting, although it would be kind of ugly to implement: do a quick any(isnan(A)), and if not, use the fast stock sorting algorithms; if there is a NaN somewhere in the array, use a version of the sort that has a tweaked comparison function so the NaNs wind up at the end and are easy to trim off. But the current situation, silently returning arrays in which the non-NaNs are unsorted, is really bad. A. M. Archibald |