perhaps you have something like this in your array and have not noticed:
[1.0 , 3.0, 0/0, ...]
the 0/0 will give you a NaN that cannot be compared to Float ... in which case you should try
[2.3,nil,1].compact.sort # => [1,2.3]
that or perhaps the same error with 1.0/0 that gives infinity (but this error is detected by ruby)
source share