title: Group and count elements and sort them by column outside the group by clause
body: <p>I have <code>links</code> table with columns <code>url</code> and <code>created_at</code>, for example:</p>
  
  <pre><code>url      |  created_at
  ex2.com  |  2
  ex1.com  |  3
  ex2.com  |  1
  ex1.com  |  4
  ex3.com  |  5
  </code></pre>
  
  <p>I'd like to group it by url, count this urls and sort by url_count and created_at of the first url in group, so result would be:</p>
  
  <pre><code>url      |  url_count
  ex2.com  |  2
  ex1.com  |  2
  ex3.com  |  1
  </code></pre>
  
  <p>I do <code>Link.select(:url).group(:url).order('count_url DESC').count</code> and now  I need only sort by created_at but I lost it's value in this query.</p>
  
  <p>How can I do this?</p>