From: Josselin Date: 2007-07-20T06:49:59+09:00 Subject: Re: array sort_by with nil elements On 2007-07-19 14:56:40 +0200, Stefan Rusterholz said: > Robert Klemme wrote: >> This does not work. >> >> irb(main):003:0> [nil].sort_by {|it| it.send(:length) || 0} >> >> Kind regards >> >> robert > > According to him, his problem is not the *element* being nil, but the > *method called upon* returning nil. So yes, this does work for the > problem he describes. >>> problem arise when one criteria like the user.name is nil > > Regards > Stefan yes you're right , I did not mention it (even thought...) the element 'user' always exist... but user can have nil display_name.... thanks to all , I keep that in my book !