From: Pit Capitain Date: 2008-08-12T03:35:23+09:00 Subject: Re: Sort array by two attributes? (like sql "order by A, B") 2008/8/11 James Coglan : > > objects.sort do |a,b| > comp = (a.lastname <=> b.lastname) > comp.zero? ? (a.firstname <=> b.firstname) : comp > end For this usecase there's also Numeric#nonzero? objects.sort do |a, b| (a.lastname <=> b.lastname).nonzero? || (a.firstname <=> b.firstname) end Regards, Pit