title: How to find the index of an array which has a maximum value
body: <p>I have an array of elements. If I do a <code>arr.max</code> I will get the maximum value. But I would like to get the index of the array. How to find it in Ruby</p>
  
  <p>For example</p>
  
  <pre><code>a = [3,6,774,24,56,2,64,56,34]
  =&gt; [3, 6, 774, 24, 56, 2, 64, 56, 34]
  &gt;&gt; a.max
  a.max
  =&gt; 774
  </code></pre>
  
  <p>I need to know the index of that <code>774</code> which is <code>2</code>. How do I do this in Ruby?</p>