def mode(array)
p array
hash = Hash.new(0)
array.each do |i|
hash[i]+=1
end
p hash
to_a = hash.to_a
p to_a
sorted = to_a.sort { |k,(a,b)| a <=> b }
p sorted
last = sorted.last
p last
end
mode(["a", "b", "c", "c", "a"])
ZGVmIG1vZGUoYXJyYXkpCiAgcCBhcnJheQogIGhhc2ggPSBIYXNoLm5ldygwKQogIGFycmF5LmVhY2ggZG8gfGl8CiAgICBoYXNoW2ldKz0xCiAgZW5kCiAgcCBoYXNoCiAgdG9fYSA9IGhhc2gudG9fYQogIHAgdG9fYQogIHNvcnRlZCA9IHRvX2Euc29ydCB7IHxrLChhLGIpfCBhIDw9PiBiIH0KICBwIHNvcnRlZAogIGxhc3QgPSBzb3J0ZWQubGFzdAogIHAgbGFzdAplbmQKCm1vZGUoWyJhIiwgImIiLCAiYyIsICJjIiwgImEiXSk=
["a", "b", "c", "c", "a"]
{"a"=>2, "b"=>1, "c"=>2}
[["a", 2], ["b", 1], ["c", 2]]
prog.rb:10:in `sort': comparison of Array with Array failed (ArgumentError)
from prog.rb:10:in `mode'
from prog.rb:16:in `<main>'