Velocity Reviews

Velocity Reviews (
-   Ruby (
-   -   how does sort work on hash (

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.