title: Sorting elements in Ruby on Rails
body: <p>I have models Topic and Post.</p>
  
  <pre><code>routes.rb
  
  resources :topics do
    resources :posts
  end
  </code></pre>
  
  <p>I want sort topics by created_at last post in this topics.</p>
  
  <pre><code>@topics = Topic.order(???)
  </code></pre>
  
  <p>Update: </p>
  
  <pre><code>Topic.includes(:posts).order("posts.created_at desc")
  </code></pre>
  
  <p>This code great work, but how order new topic without posts? New topic without posts must be first in top.</p>