On 3/23/11 Wed Mar 23, 2011 12:49 PM, "Chris Stinemetz" <cstinem...@cricketcommunications.com> scribbled:
> Jim, > > I have another question. > > How do I sort the results so it is from smallest to largest starting with > $cell,$sect,$carr? It is difficult to sort a multi-level, nested hash. I would transfer the values to an array-of-arrays and sort that: #!/usr/local/bin/perl use warnings; use strict; my %sum; while (<DATA>){ next unless /;/; chomp; my @data = split /;/; my($cell,$sect,$chan,$carr,$rlptxat1,$dist,$precis) = @data[31,32,38,39,44,261,262]; $sum{$cell}{$sect}{$chan} += $rlptxat1 || 0; } my @data; for my $cell ( sort keys %sum ) { for my $sect ( sort keys %{$sum{$cell}} ) { for my $chan ( sort keys %{$sum{$cell}{$sect}} ) { push( @data, [ $sum{$cell}{$sect}{$chan}, $cell, $sect, $chan ]); } } } for my $record ( sort { $a->[0] <=> $b->[0] } @data ) { my( $val, $cell, $sect, $chan ) = @$record; print "The value of ($cell,$sect,$chan) is $val\n"; } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/