title: Sort a list of objects by using their attributes in Ruby
body: <p>I have a list of <code>Fruit</code> structs called <code>basket</code>. Each <code>Fruit</code> struct has a <code>name</code> (a string) and a <code>calories</code> (an integer). I would like to sort <code>basket</code> so that:</p>
  
  <ol>
  <li><p>The <code>Fruit</code>s with the highest <code>calories</code> appear first. For example, a fruit with 500 calories appears before a fruit with 400 calories.</p></li>
  <li><p>If two <code>Fruit</code>s have equal <code>calories</code>, the <code>Fruit</code> whose <code>name</code> comes first alphabetically comes first, ignoring case. For example, given two fruits with equal calories, one named "banana" will come before one named "Citrus".</p></li>
  </ol>
  
  <p>The definition of <code>Fruit</code> is not something I control so I'd prefer a solution which doesn't involve mixing anything into <code>Fruit</code> or changing it. Is this possible?</p>