title: Efficient sorting of rows by multiple columns in Rails 3
body: <p>I have a table name transactions with following columns</p>
  
  <pre><code>created_at        | debit | credit | balance | account_id
  2012-2-2 02:22:22 | 3000  | 0      | 0       | 8
  2012-2-2 07:22:22 | 500   | 1000   | 0       | 8
  2012-2-2 09:22:22 | 0     | 8000   | 0       | 8
  
  2012-3-3 19:17:20 | 1000  | 0      | 0       | 8
  2012-3-3 04:02:22 | 0     | 8000   | 0       | 8
  </code></pre>
  
  <p>Before calculating balance I need to</p>
  
  <ul>
  <li>sort transactions by date (i.e. daily)</li>
  <li>then sort by debit (higher debit must come first)</li>
  </ul>
  
  <p>I have a million transactions distinguished by account_id. What is efficient way of sorting in such a scenario ?</p>
  
  <p>Any answer will be appreciated.</p>