19/19


#1

Is it possible to get the list of fruits using .each and sort it?
I've tried as follows but it doesn't work


#2

fruits = ["orange", "apple", "banana", "pear", "grapes"]
fruits.sort!
fruits.reverse!
fruits.each do |fruit|
    puts fruit
end

Like this? You just gotta understand that the computer runs line by line.


#3

Thanks
Now I do understand))


#4

try this
fruits.sort!.reverse! {|x, y| x <=> y}