Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   how does sort work on hash (http://www.velocityreviews.com/forums/t832585-how-does-sort-work-on-hash.html)

hemant kumar 08-19-2006 06:53 AM

how does sort work on hash
 

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.





All times are GMT. The time now is 04:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.