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

···

--
Posted via http://www.ruby-forum.com/.

Assuming ActiveRecord: ActiveRecord::Base

···

On Fri, Dec 17, 2010 at 1:00 PM, Arun Kumar <jakheart001@gmail.com> wrote:

Hi all,

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

--
Phillip Gawlowski

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.