How to add conditon in select method

Hi all,

How to add the condition for “order by birthdate desc” in the following

User have friends
User have profile

now = Date.today
end = now + 7.days

u= User.find(id)
@somevariable = u.friends.select{|f|
date = f.profile.birthdate if f.profile
selected = false
if date
if (now.month == date.month) && (date.day >= now.day && date.day <=
end_day.day )
selected =true
elsif (end.month == date.month) && (date.day <= end.day &&
end_day.month != today.month)
selected = true
else
selected=false
end
end
selected }

The above query is working fine but the order is displaying based on
alphabet,
But i need to show by soonest date (birthdate)
How to achieve this by using order by or any other method ?

Thanks in advance,
Jak

On Fri, Dec 17, 2010 at 1:00 PM, Arun K. [email protected]
wrote:

Hi all,

How to add the condition for “order by birthdate desc” in the following

Assuming ActiveRecord:


Phillip G.

Though the folk I have met,
(Ah, how soon!) they forget
When I’ve moved on to some other place,
There may be one or two,
When I’ve played and passed through,
Who’ll remember my song or my face.