My input hash: h = { "a" => 20, "b" => 30, "c" => 10 }
Ascending sort: h.sort {|a,b| a[1]<=>b[1]} #=> [["c", 10], ["a", 20], ["b", 30]]
But, I need [["b", 30], ["a", 20], ["c", 10]]
How is can we make it work the other way around, what does <=>
mean?