I am trying to get all the keys with the same value from a hash and put them into an array as separate entries. I have this line of code but it sends everything in as a sing
Or even better, yet simpler:
h.select { |k,v| v == h.values.max }.keys
For example,
h = { "a" => 1, "b" => 2, "c" => 2 } # implement the above solution h.select { |k,v| v == h.values.max }.keys #=> ["b", "c"]
Hopefully, that's what you'd want! :)