Hello I\'m trying to find the largest value in my hash. I made a search in google and I found this code:
def largest_hash_key(hash) key = hash.sort{|a,b|
You can modify your method's first statement to
key = hash.sort{|a,b| a[1] <=> b[1]}.last[0]
Hash.sort returns an array of key-value pairs. last gets you the key-value pair with the largest value. Its first element is the corresponding key.
Hash.sort
last