Q:

Trying to pass a array to a method to be sorted

Codeacademy actually passed this code as correct but got these errors when built in irb. I'm lost!
Errors: (ruby):1: warning: found = in conditional, should be ==
(ruby):8: syntax error, unexpected keyword_end, expecting $end   
    def alphabetize(arr, rev=false)
    if rev = true
        arr.sort! { |item1, item2| item2 <=> item1 }
    else 
        arr.sort! { |item1, item2| item1 <=> item2 }
    end
end
    puts arr
end
alphabetize("the", "world", "is", "a", "vampire")

A:

Write if rev = true as if rev == true(but more Rubyish is if rev). There is an extra end also just above puts arr, remove it.
def alphabetize(arr, rev=false)
  if rev 
    arr.sort! { |item1, item2| item2 <=> item1 }
  else 
    arr.sort! { |item1, item2| item1 <=> item2 }
  end
end

puts alphabetize(["the", "world", "is", "a", "vampire"])

