I have this array, for example (the size is variable):
x = [\"1.111\", \"1.122\", \"1.250\", \"1.111\"]
and I need to find the most comm
Using the default value feature of hashes:
>> x = ["1.111", "1.122", "1.250", "1.111"] >> h = Hash.new(0) >> x.each{|i| h[i] += 1 } >> h.max{|a,b| a[1] <=> b[1] } ["1.111", 2]