in reply to Retaining Insertion order throughout when using “map”
use strict; use warnings; my %hashA = ( 'accord newton second' => 80, 'acceler smaller greater' => 78, 'addit law motion' => 56, 'meant bodi act forc'=> 55, ); my %hashB = ( 2 => 'addit law motion', 3 => 'accord newton second', 4 => 'meant bodi act forc', 5 => 'acceler smaller greater', ); my %hashC = ( 2 => "In addition to ", 3 => "According to Newton", 4 => "It also meant that whenever ", 5 => "The acceleration is", ); my @insertionOrderA = sort {$hashA{$b} <=> $hashA{$a}} keys %hashA; my %reversehashB = reverse %hashB; foreach (@insertionOrderA) { print "$reversehashB{$_} $hashC{$reversehashB{$_}}\n"; }
I hope this is of use.
Cheers,
JohnGG
|
|---|