how does sort work on hash

H

hemant kumar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,209
Messages
2,571,089
Members
47,689
Latest member
kilaocrhtbfnr

Latest Threads

Top