numbers = [11, 2, 5, 7, 3]
numbers = numbers.sort
# numbers is [2, 3, 5, 7, 11]
puts "numbers is #{numbers}"
# descending
numbers = numbers.sort {|x, y| y <=> x }
# numbers is [11, 7, 5, 3, 2]
puts "numbers is #{numbers}"
lst = [['B', 3], ['A', 2], ['C', 1]]
lst = lst.sort {|x, y| x[0] <=> y[0] }
# arr is [['A', 2], ['B', 3], ['C', 1]]
puts "lst is #{lst}"
lst = lst.sort {|x, y| y[1] <=> x[1] }
# arr is [['B', 3], ['A', 2], ['C', 1]]
puts "lst is #{lst}"