in reply to Retaining Insertion order throughout when using “map”

I think this is what you want. It produces your (updated, I was scratching my head at first :-) desired output. However, you imply that the text files, particularly for %hashA are already sorted. Perhaps you should consider changing the hash for a list so that the order is preserved as you read the data in.

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