Ruby中的浮点数排序

def 排序
  排序数组=["0.001","0.123","1.23","6.5","9","10.00","23.61","45.01","56"]
  数组 = []
  排序数组.each { |i|
    数组 << i.to_f
  }
  for k in (0..数组.length-2)
    for h in (1..数组.length-1)
      unless 数组[h]<数组[h-1]
        (数组[h],数组[h-1]= 数组[h-1],数组[h])
      end
    end
  end
  p 数组
end

你可能感兴趣的:(Ruby中浮点数排序问题)