fork download
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4.  
  5. my %tmp = (
  6. "key1" => 3,
  7. "key2" => 6,
  8. "key3" => 1,
  9. "key4" => 3,
  10. );
  11.  
  12. for my $key ( sort { $tmp{$b} <=> $tmp{$a} } keys %tmp ) {
  13. printf "%s => %d\n", $key, $tmp{ $key };
  14. }
Success #stdin #stdout 0s 6044KB
stdin
Standard input is empty
stdout
key2 => 6
key4 => 3
key1 => 3
key3 => 1