What's going on?


#1

Here's my code for section 5:

numbers = [5, 4, 16, 67, 4, 3, 6, 8, 19]
def alphabetize(arr, rev=false)
arr.sort!
if rev
arr.sort!
else
arr.reverse!
end
return arr
end

puts "#{alphabetize(numbers)}

If, in the second line, I use 'number.sort!', the code passes, but still has an error code. If, on the other hand, I use 'arr.sort!' like the code above, there's what looks like the right output, but it doesn't pass.

#2

@jswald17,
Try it with

puts alphabetize(numbers,rev=true).inspect
puts alphabetize(numbers,rev=false).inspect

#3

I found out what the problem was... the second line of code:

numbers.sort!

was unnecessary.