From: "F. Senault" Date: 2007-07-19T21:55:02+09:00 Subject: Re: array sort_by with nil elements Le 19 juillet � 14:32, Robert Klemme a �crit : > This does not work. > > irb(main):003:0> [nil].sort_by {|it| it.send(:length) || 0} >> [nil, "aaaaaaa", "aaa", "a" ].sort_by {|it| (it && it.send(:length)) || 0} => [nil, "a", "aaa", "aaaaaaa"] (Or even without the parenthesis.) Fred -- An ASCII character walks into a bar and orders a double. 'Having a bad day?' asks the barman. 'Yeah, I have a parity error,' replies the ASCII character. The barman says, 'Yeah, I thought you looked a bit off.' (Kirrily 'Skud' Robert)