From: Brian Candler Date: 2009-01-15T01:11:50+09:00 Subject: Re: a beginner case question Taylor Strait wrote: > when 'reverse_alpha' then answers.sort_by {|answer| answer.text} > return answers.reverse What you're doing here may be clearer if you write it out like this: when 'reverse_alpha' answers.sort_by {|answer| answer.text} return answers.reverse What's happening is (1) the answers.sort_by... line is creating a new sorted array - and then discarding this array. (2) The last line then returns the original 'answers' array, reversed. You could fix this by: when 'reverse_alpha' answers.sort_by {|answer| answer.text}.reverse The value of this whole expression becomes the value result of the case statement, which in turn becomes the return value of the method. If you really did need to use 'return' to drop straight out of the method, you could do when 'reverse_alpha' answers = answers.sort_by {|answer| answer.text} return answers.reverse Or just: when 'reverse_alpha' return answers.sort_by {|answer| answer.text}.reverse -- Posted via http://www.ruby-forum.com/.