There is also the IEEE 754 totalOrder if all the numbers have the same type:

struct Float64
def self.total_order(x : self, y : self) : Int32
xi = x.unsafe_as(Int64)
yi = y.unsafe_as(Int64)
xi ^= Int64::MAX if xi < 0
yi ^= Int64::MAX if yi < 0
xi <=> yi
end
end
arr = [1.0 / 0, -0.0, 0.0 / 0, -1.0 / 0, 0.0]
arr.sort { |x, y| Float64.total_order(x, y) } # => [NaN, -Infinity, -0.0, 0.0, Infinity]
arr.sort_by {|x|
xi = x.unsafe_as(Int64)
xi < 0 ? xi ^ Int64::MAX : xi
} # => [NaN, -Infinity, -0.0, 0.0, Infinity]