title: Rails order by results count of has_many association
body: <p>Is there anyway I can order the results (<code>ASC</code>/<code>DESC</code>) by number of items returned from the child model (<code>Jobs</code>)?</p>
  
  <pre><code>@featured_companies = Company.joins(:jobs).group(Job.arel_table[:company_id]).order(Job.arel_table[:company_id].count).limit(10)
  </code></pre>
  
  <p>For example:  I need to print the Companies with highest jobs on top</p>