My solution (that works) for 5. Sorting With Control Flow


#1

Hi, this solution with two return works well!

def alphabetize(arr, rev=false)
    arr.sort!
    if rev
        return arr.reverse!
    else
        return arr
    end
end

numbers = [6,10,3,44,-5]

puts "#{alphabetize(numbers)}"

#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.