### Louis Pouzin wrote:
### > Hi, Just trying to understand hash of hash of array.
### > my %LIS; my $pet='dog';my $x='fido'; my $y=5; my $z='male';
### > $LIS{$pet}{$x} = [$y,$z];
### > print "@{$LIS{$pet}{$x}}"; # ok, prints '5 male'
### > Now, suppose %LIS is populated with lots of pets.
### > How to get a list of the $z sorted on $y for the dogs ?
### > my @LIS = sort { ????? }@{$LIS{'dog'}{$x}}; ???
### > Thanks
###
###
### Better invest a bit more in meaningful names and in more data:
my %LIS;
my $pet='dog';
my $name='Fido';
my $age=5;
my $gender='male';
$LIS{$pet}{$name} = [$age,$gender];
$pet='dog';
$name='Woffo';
$age=8;
$gender='male';
$LIS{$pet}{$name} = [$age,$gender];
$pet='cat';
$name='Maunz';
$age=2;
$gender='female';
$LIS{$pet}{$name} = [$age,$gender];
$pet='bird';
$name='Pieps';
$age=1;
$gender='male';
$LIS{$pet}{$name} = [$age,$gender];
print "- - - - my HoHoL: - - - -\n";
for $keysPet(keys %LIS) {
print $keysPet, "\n";
for $keysName( keys %{$LIS{$keysPet}} ) {
printf " %-6s %2s %-12s \n",
$keysName, $LIS{$keysPet}{$keysName}[0],
$LIS{$keysPet}{$keysName}[1];
push @lis, $LIS{$keysPet}{$keysName}[0], ### (1)
sprintf "\n%-6s %-6s %2s %-12s ", $keysPet,
$keysName, $LIS{$keysPet}{$keysName}[0],
$LIS{$keysPet}{$keysName}[1]; } }
%lis = @lis; ### (2)
print "\n\n- - - - by age: - - - -\n";
for (sort(keys %lis)) { ### (3)
print $lis{$_} }
### According to my present opinion I can only sort lists
### but not a wide branched and feathered hashes landscape;
### so I have to push my data into an appropriate list (1),
### copy that list to a hash (2) and print them after sorting (3).
###
### Regards, Detlef