Ruby - Operators and Expressions
How can you use the spaceship operator to sort an array of strings arr = ['apple', 'banana', 'cherry'] in reverse alphabetical order?
How can you use the spaceship operator to sort an array of strings arr = ['apple', 'banana', 'cherry'] in reverse alphabetical order?
arr.sort { |a, b| b <=> a } to reverse order.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions