title: How to find the max value in an array of hashes?
body: <p>Given this array of hashes here:</p>
  
  <pre><code>arr = [{:question_type=&gt;"Fire", :total=&gt;0.0}, {:question_type=&gt;"Water", :total=&gt;0.0}, {:question_type=&gt;"Metal", :total=&gt;0.0}, {:question_type=&gt;"Earth", :total=&gt;0.0}, {:question_type=&gt;"Wood", :total=&gt;100.0}]
  </code></pre>
  
  <p>I would like to pick the hash with the highest value for the total key.
  So the code bellow seems to do the work</p>
  
  <pre><code>max = arr.max_by{|x| x[:total]}
  puts max[:question_type]
  #=&gt; Wood
  </code></pre>
  
  <p>However if I have 2 hashes with the same value it will return the first one only</p>
  
  <pre><code>arr2 = [{:question_type=&gt;"Fire", :total=&gt;0.0}, {:question_type=&gt;"Water", :total=&gt;0.0}, {:question_type=&gt;"Metal", :total=&gt;0.0}, {:question_type=&gt;"Earth", :total=&gt;50.0}, {:question_type=&gt;"Wood", :total=&gt;50.0}]
  
  max = arr2.max_by{|x| x[:total]} #it should be arr2
  puts max[:question_type]
  #=&gt; Earth
  </code></pre>
  
  <p>What would be the best way to get it to return <code>Earth</code> and <code>Wood</code> in case both are the highest values?</p>