#!/usr/perl/bin
use strict;
use Data::Dumper;
my %h=(
"Alex"=>24,
"Sam"=>25,
"Bob"=>30,
"Andy"=>11,
"Wills"=>35,
"Mary"=>16,
"Helen"=>24
);
print(Dumper(\%h)); # output original hash
my @keys = sort { $h{$b} <=> $h{$a} } keys %h; #sort the hash table
for (@keys){print "$_ -> $h{$_}\n"}
阅读(1186) | 评论(0) | 转发(0) |