I want to return a hash key/value pair based on max key value. I know max_by
works, but it stops at the first result. How can I return all results in the event of a tie?
{
foo: 1,
bar: 3,
baz: 3
}.max_by { |key, value| value }
#=> [:bar 3] # Only bar comes back, but baz also has a value of 3.
I'd do :
Breaking of the above code :