in reply to Sorting hash references

One possibility that I've considered using before is storing in your hash the insertion order.

Consider the following code:

my %hash; my $count = 0; while ( my $line = <DATA> ) { chomp $line; next unless $line; my ( $key, $value ) = split /\s*=\s*/, $line; $hash{$key} = { 'Order' => $count++, 'Value' => $value }; } my @ordered_keys = sort { $hash{$a}{Order} <=> $hash{$b}{Order} } keys %hash; print "$_ = $hash{$_}{Value}\n" for @ordered_keys; __DATA__ Bart = Simpsons Elane = Seinfeld Ross = Friends Oscar the Grouch = Sesame Street


Dave