title: Rails - Order by the average of an association
body: <p>I am struggling to add a sorting feature in my fake imdb copycat website.</p>
  
  <p>I have movies that have many reviews through an association. Unfortunately I can't find how to order the @movies object by review average for the index page.</p>
  
  <p>Obviously, this</p>
  
  <pre><code>includes(:reviews).order("reviews.rating_out_of_ten desc")
  </code></pre>
  
  <p>doesn't work has it only order by the first review of each movie. 
  How can I write it so that it order by the average of all associated reviews ??</p>
  
  <p>Many thanks in advance</p>