10.5. Sorting with control flow

Hi guys,

This is what I got for 10.5 and it works.

def alphabetize(arr,rev=false)
if rev == true
puts arr.reverse!
number = [2,4,7,8,9,10,15]
puts alphabetize {|number|}

Im confused cuz I realized other’s answers are different from mine. I need verification.


Hi Aden,

There will always be several ways to solve a problem in code, so don’t worry if your code is different from other peoples’. If your code works and you’re being passed, don’t worry about it :slight_smile:
Your code wouldn’t work for me though, it was throwing an error on the console, so maybe you should compare your code to some other peoples’ this time.

Looks like you’re trying to sort the method instead of the array. So instead of alphabetize.sort! you should have arr.sort!

1 Like