Can not understand how the block after sort works! Need help. thanks.

   h = { "a" => 20, "b" => 30, "c" => 10  }
   puts h.sort                     #=> [["a", 20], ["b", 30], ["c", 10]]
   puts h.sort {|a,b| a[0]<=>b[0]} # as above
   puts h.sort {|a,b| a[1]<=>b[1]} #=> [["c", 10], ["a", 20], ["b", 30]]

I:\RubyNV>zzz-tut6-hash.rb
a
20
b
30
c
10

a
20
b
30
c
10

c
10
a
20
b
30

I:\RubyNV>
-- 
Posted via http://www.ruby-forum.com/.