I have a hash which is something like this
{"red" => 3, "blue" => 1, "yellow" => 3, "green" => 1, "black" => 4}
I want to sort and display the top three colors in the order of the hash's values i.e
["black", "red", "yellow"]
I tried to do something like sort_by { |x,y| h[x] <=> h[y] }
and max_by { |x,y| h[x] }
, but I only get ["black"]
. How do you get the top three occurrences?