This could probably be improved dramatically, but off the top of my head:
count.group_by{|k,v| v}.max_by{|k,v| k}.last.map(&:first)
First, group the key/value pairs of the hash so that the ones with the same value are in the same groups:
count.group_by{|k,v| v} #=> {2=>[[4, 2]], 3=>[[5, 3], [6, 3]], 1=>[[7, 1]]}
Then get the group with the maximum value:
.max_by{|k,v| k} #=> [3, [[5, 3], [6, 3]]]
Now, we just want the original keys out of that, so first we take the last element of the pair:
.last #=> [[5, 3], [6, 3]]
And we want just the first element of each of those nested pairs:
.map(&:first) #=> [5, 6]
This approach avoids one pass through the map as compared to the select
-based solutions. It's probably not a significant performance win unless the data set is really huge, in which case the intermediate data structures being built by my solution will be more of a problem anyway.