From: Robert Klemme Date: 2007-07-19T17:27:42+09:00 Subject: Re: array sort_by with nil elements 2007/7/19, Josselin : > I am using the sort_by command > > @buddies = @user.buddies.compact.sort_by {|item| item.send @criteria} > > > problem arise when one criteria like the user.name is nil the sort > crash.... anyway to avoid it Add a rescue modifier. @buddies = @user.buddies.compact.sort_by {|item| item.send @criteria rescue nil} Kind regards robert