sort_by DESC

Well, yeah:   .sort_by{|t| - t.created_at.to_i} #Note the negation

But why not do:

class User    has_many :type1s, :order => 'created_at DESC';    has_many :type2s, :order => 'created_at DESC';    has_many :type3s, :order => 'created_at DESC';    has_many :type4s, :order => 'created_at DESC';    def types      (self.type1s + self.type2s +       self.type3s + self.type4s).sort_by{|t| - t.created_at.to_i}    end end

That might not map properly to your real problem, but then you haven't given your real code.

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com

@types = (@type_1, @type_2, @type_3, @type_4).sort {|a, b| b.created_at <=> a.created_at}