Just wondering how to sort an array of floats in Ruby, since "sort" and "sort!" only work for integer arrays.
Arrays of floats can certainly be sorted:
>> [6.2, 5.8, 1.1, 4.9, 13.4].sort
=> [1.1, 4.9, 5.8, 6.2, 13.4]
Maybe you have a nil
in your array, which can't be sorted with anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With