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
相關文章
相關標籤/搜索