Thanks all, yes that worked.

Rob Dixon <[EMAIL PROTECTED]> wrote:
Tfbsr Bertrand wrote:
>
> How do I sort a hash that has values of PASS or FAIL
> would like to put all FAILS at the top.
> I tried code elow but did not work
>
> Thanks
>
> foreach my $key (sort {$status{a} cmp $status{b}} keys %status) {
> #foreach my $key (sort keys %status)
> print "$key";
> print "$status{$key}";
> print "$key\n>";
> }

Hi.

Something like the program below?

HTH,

Rob



my %hash = (
A => 'FAIL',
B => 'FAIL',
C => 'PASS',
D => 'FAIL',
E => 'PASS',
F => 'PASS',
G => 'PASS',
H => 'FAIL',
);

my @sorted_keys = sort { $hash{$b} cmp $hash{$a} } keys %hash;

foreach (@sorted_keys) {
print "$_ => $hash{$_}\n";
}

**OUTPUT

F => PASS
G => PASS
C => PASS
E => PASS
A => FAIL
B => FAIL
D => FAIL
H => FAIL

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

Reply via email to