Don't see why that'd be a bad idea, though of course it would be a bad idea if your predicate function didn't account for such beasts (such as the above predicate).
It depends on the sorting algorithm you use, but with, for example, mergesort, sorting with NaNs will result in non-NaN elements being placed out of order -- the presence of a NaN will turn merging into concatenation. Quicksort on the other hand will simply intersperse NaNs throughout the output. Heapsort might handle NaNs pretty well though.
Sure. But if your predicate function is written appropriately--that is, not using simple less-than/greater-than comparison--then NaNs will be sorted appropriately as well.
1
u/froydnj Sep 26 '10
Don't see why that'd be a bad idea, though of course it would be a bad idea if your predicate function didn't account for such beasts (such as the above predicate).