r/programming • • Sep 25 '10

Omega - Language of the Future | Lambda the Ultimate

http://lambda-the-ultimate.org/node/4088
60 Upvotes

126 comments sorted by

View all comments

Show parent comments

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).

1

u/shrughes Sep 26 '10

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.

1

u/froydnj Sep 26 '10

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.