title: Ruby finding element with max value in multidimensional array using max_by
body: <p>I'm trying to implement <code>max_by</code> to find element with highest value  in multidimensional array.<br>
  code as follows  </p>
  
  <pre><code>ar = [[123,345,43,35,43,1],[456,123,43,35,43,1],[675,123,43,35,43,1],[123,123,43,35,43,321]]
  x = ar.max_by { |a,b| a &lt;=&gt; b }
  p "result #{x.inspect}"
  </code></pre>
  
  <p>And the output is <code>" result [456, 123, 43, 35, 43, 1]"</code>
  Can you please explain to me what's wrong with my code ?</p>
  
  <p><strong>Update 1</strong><br>
  using max_by</p>
  
  <pre><code>ar  = [ {a:1},{a:2},{a:3}]
  x = ar.max_by { |e| e[:a] }
  p "result #{x.inspect}"
  </code></pre>
  
  <p>I've left this update as a reminder for myself of whoever may bump into similar problem</p>