How do you order by two conditions?

For instance, if I wanted to order by “created_at”, then order that
again by “last_contacted”, how would I do so?

I tried something like this, but unfortunately didn’t work: :order =>
‘created_date DESC, last_contacted ASC’

Any ideas?

On 8/24/07, Bob S. [email protected] wrote:

erm, it didn’t? Did you get an error or did it just not return the
records in the order you expected? Because that looks like it should
work fine…


I’m assuming that you meant to write:

:order => “created_at DESC, last_contacted ASC”

Instead of

:order => “created_date DESC, last_contacted ASC”

But, other than that it looks fine. You could even drop the ASC if
you want, since that’s the default in SQL.

:order => “created_at DESC, last_contacted”