title: How to sort collection by created_at attribute
body: <p>I'm working with Ruby on Rails 2.3.8 and I've got a collection that is built from other two collections, as follows:</p>
  
  <pre><code>@coll1 = Model1.all
  @coll2 = Model2.all
  
  @coll = @coll1 &lt;&lt; @coll2
  </code></pre>
  
  <p>Now, I would like to sort that collection by <code>created_at</code> attribute in descendant order. So, I did the following:</p>
  
  <pre><code>@sorted_coll = @coll.sort {|a,b| b.created_at &lt;=&gt; a.created_at}
  </code></pre>
  
  <p>And I've got the following exception:</p>
  
  <pre><code>undefined method `created_at' for #&lt;Array:0x5c1d440&gt;
  </code></pre>
  
  <p>eventhought it exists for those models.</p>
  
  <p>Could anyboy help me please?</p>