[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how does sort work on hash

hemant kumar

8/19/2006 6:54:00 AM


I am just a little curious about how exactly sort workes on hashes.

for example:
a = {:foo => 10,:bar => 5,:duh => 20}

a.sort {|x,y| y[1] <=> x[1]}


now how exactly the above line works.the block is passed two elements at a
time, as array? If yes, how sort treates the next two elements?

what algorithm this sort is based on? Is it inplace sorting? or only sort!
does inplace sorting?

May be the question is not so much about hashes.