Sorting an array of Doubles with NaN in it

后端 未结 5 1934
深忆病人
深忆病人 2021-01-11 10:26

This is more of a \'Can you explain this\' type of question than it is anything else.

I came across a problem at work where we were using NaN values in a table, but

5条回答
  •  一生所求
    2021-01-11 10:47

    I believe that's because

    a < NaN == false
    a > NaN == false
    a == NaN == false
    

    so the comparison on them breaks down, and that throws off the entire sort.

提交回复
热议问题