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.
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.