Files
dockerfiles/tests/ruby/testcase/soryarraybyalphabet.rb
T
2019-08-04 22:54:34 -07:00

8 lines
358 B
Ruby

books = ["Charlie and the Chocolate Factory", "War and Peace", "Utopia", "A Brief History of Time", "A Wrinkle in Time"]
# To sort our books in ascending order, in-place
books.sort! { |firstBook, secondBook| firstBook <=> secondBook }
# Sort your books in descending order, in-place below
books.sort! { |secondBook, firstBook| firstBook <=> secondBook }