运维网's Archiver
论坛
›
Perl
› perl hash按照value排序打印
heike2
发表于 2015-12-29 10:44:32
perl hash按照value排序打印
#!/usr/bin/perl -w
use strict;
my %hash = ( a => 3, b => 1, c => 4);
map{ print "$_ => $hash{$_}\n"}
sort{ $hash{$b} <=> $hash{$a} } keys %hash;
页:
[1]
查看完整版本:
perl hash按照value排序打印