From: Aleksandar Lazic Date: 2006-10-29T23:53:11+09:00 Subject: How can i do 'foreach (reverse sort { $hasref->{$a} <=> $hasref->{$b} } keys %{$hasref})..' in ruby Hi, I'am new with ruby and want to migrate some of my perlscripts to ruby ;-). I have a problem with the 'reverse sort' of values of a hashref and hope that sombody can help me or point me to the right way ;-) I have found the a nice answer http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/30322 and have try the follwoing commands: clients.values.sort{|a,b| a[1] <=> b[1]}.each {|k,v| puts "#{k} => #{v}" } clients.values.sort.reverse.each { |k| puts "#{k}" } but it looks to me that sort give me only a array back. Here my perl code which i want to translate: --- foreach (reverse sort { $hasref->{$a} <=> $hasref->{$b} } keys %{$hasref}){ printf("% 7i %s\n",$hasref->{$_}, $_); #^^^^^^^Key output ^^value output } --- Thanks for help Aleks