From: Taylor Strait Date: 2009-01-15T00:56:54+09:00 Subject: a beginner case question I am using case in to determine the sorting method used for an array as so: def single_choice(object) # sort answer order based on question.list_method answers = object.answers sorted_answers = case object.list_method when 'position' then answers.sort_by {|answer| answer.position} when 'random' then answers.sort_by {rand} when 'alphabetical' then answers.sort_by {|answer| answer.text} when 'reverse_alpha' then answers.sort_by {|answer| answer.text} return answers.reverse when 'shortest_first' then answers.sort_by {|answer| answer.text.length} when 'longest_first' then answers.sort_by {|answer| answer.text.length} return answers.reverse end This does not because of the return statements. However, I need to reverse the result for those two options. How can I do this with case statements? Or must I use if..elsif? -- Posted via http://www.ruby-forum.com/.