title: Sorting: Sort array based on multiple conditions in Ruby
body: <p>I have a mulitdimensional array like so:</p>
  
  <pre><code>[
    [name, age, date, gender]
    [name, age, date, gender]
    [..]
  ]
  </code></pre>
  
  <p>I'm wondering the best way to sort this array based on multiple conditions...For instance, how would I sort based on <strong>age</strong> <em>first</em> then by name?</p>
  
  <p>I was messing around with the <code>sort</code> method like so:</p>
  
  <pre><code>array.sort { |a,b| [ a[1], a[0] ] &lt;=&gt; [ b[1], b[0] ] }
  </code></pre>
  
  <p>Besides that I don't really understand this syntax, I'm not getting the results I would expect.  Should I be using the <code>sort</code> method?  Should I be individually comparing results by <code>mapping</code> the array?</p>