in reply to Hash sorting
# Pull out a list of records my @data; foreach my $section (keys %hash) { foreach my $item (keys %{$hash{$section}}) { push @data, [$hash{$section}{$item}, $section, $item]; } } # sort it @data = sort { $b->[0] <=> $a->[0] or $a->[1] cmp $b->[1] or $a->[2] cmp $b->[2] } @data; # Print it. print "Count Section Item\n"; foreach my $record (@data) { printf("%5d %7s %7s\n", @$record); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Hash sorting
by jdporter (Paladin) on May 12, 2003 at 19:17 UTC | |
by tilly (Archbishop) on May 12, 2003 at 19:56 UTC | |
by Util (Priest) on May 13, 2003 at 05:09 UTC | |
by tye (Sage) on May 13, 2003 at 15:09 UTC | |
|
Re: Re: Hash sorting
by Util (Priest) on May 13, 2003 at 05:09 UTC | |
by tilly (Archbishop) on May 13, 2003 at 15:38 UTC | |
by Aristotle (Chancellor) on May 13, 2003 at 14:06 UTC | |
|
Re: Re: Hash sorting
by jdporter (Paladin) on May 13, 2003 at 14:19 UTC |