title: Sort hashes in array alphabetically by a field
body: <p>I'd think this would be easy, and have searched for this pretty hard, but can't seem to get it to work.</p>
  
  <p>I have the following hash:</p>
  
  <pre><code>@friends = [{"name"=&gt;"John Smith", "id"=&gt;"12345"}, {"name"=&gt;"Jane Doe", "id"=&gt;"23456"}, {"name"=&gt;"Samuel Jackson", "id"=&gt;"34567"}, {"name"=&gt;"Kate Upton", "id"=&gt;"45678"}]
  </code></pre>
  
  <p>I'm trying to sort it alphabetically by the name.</p>
  
  <p>Right now I"m doing this:</p>
  
  <pre><code>@friends.sort{|a,b| a[0]&lt;=&gt;b[0]}
  </code></pre>
  
  <p>However, it just outputs the full results in non-alphabetical order.</p>