Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ary = [3, 5, 13, 12, 0]
- # Regular sort, then reverse
- ary.sort.reverse
- # => [13, 12, 5, 3, 0]
- # Descending-order sort using a Schwartzian transform
- ary.sort_by { |x| -x }
- # => [13, 12, 5, 3, 0]
- # Descending-order sort using map and sort
- ary.map { |x| -x }.sort.map { |x| -x}
- # => [13, 12, 5, 3, 0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement