Cons of using reverse!


Hi, I am wondering why for exercise 19 we are asked to use either <=> or else/elsif/else to compare and sort your fruits when reverse! would work better and be more concise.

fruits = ["orange", "apple", "banana", "pear", "grapes"]


fruits = ["orange", "apple", "banana", "pear", "grapes"]
fruits.sort! do |firstfruit, secondfruit| secondfruit <=> firstfruit end


It's not about which method is the best. It's what they tell you to do. They want you to practice using the <=> operators and the if/else if/else statements.

They didn't ask you "hey use the best concise method!"