This is not a trick question:
[1,2,3].sort_by { |x, y| x <=> y }
=> [1, 2, 3]
[1,2,3].sort_by { |x, y| y <=> x }
=> [1, 2, 3]
What's going on here? I would have expected the arrays to be opposite one another (as they are with sort and the same parameters).
sort
andsort_by
. But I do always appreciate being told to RTFM. That's the spirit of StackOverflow.