title: Sort Array By Date Attribute, Ordered By Nearest to Current Time
body: <p>I have an Array of Contact objects...</p>
  
  <pre><code>[#&lt;Contact id: 371, full_name: "Don Hofton", birthday: "2013-11-07"&gt;,...]
  </code></pre>
  
  <p>And I need to order them by birthdays nearest to the current time AND remove objects from the array that have birthdays greater than 4 months away.  Here is what I've got so far, but it's not working....</p>
  
  <pre><code>@contacts_with_birthday_data = Contact.where(:user_id =&gt; current_user.id).where("birthday IS NOT NULL")
          @current_time = Time.now
          @contacts_with_birthday_data.each do |c|
              c.birthday = c.birthday[0..4]
              c.birthday = Date.parse(c.birthday)
          end
          @contacts_with_birthday_data = @contacts_with_birthday_data.sort! { |a,b| b[:birthday] &lt;=&gt; a[:birthday] }
          @contacts_with_birthday_data = @contacts_with_birthday_data.sort! { |a| a.birthday &lt; DateTime.now }
  </code></pre>