Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
thanksmy %hash1; $hash1{'1'} = 1; $hash1{'2'} = 1; $hash1{'3'} = 1; $hash1{'4'} = 1; $hash1{'5'} = 1; my %hash2; $hash2{'1'}{key} = 'a'; $hash2{'2'}{key} = 'b'; $hash2{'3'}{key} = 'a'; $hash2{'4'}{key} = 'a'; $hash2{'5'}{key} = 'b'; foreach my $key1 ( sort { $a <=> $b } keys %hash1 ) { print "key $key1 and $hash2{$key1}{key} \n"; } key 1 and a key 2 and b key 3 and a key 4 and a key 5 and b how to sort the above to get the below required output:- ------------------------------------------------------- key 1 and a key 3 and a key 4 and a key 2 and b key 5 and b
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash sort
by choroba (Cardinal) on May 31, 2017 at 15:12 UTC | |
by Anonymous Monk on May 31, 2017 at 15:32 UTC | |
by shmem (Chancellor) on May 31, 2017 at 16:16 UTC | |
|
Re: hash sort
by Corion (Patriarch) on May 31, 2017 at 15:21 UTC | |
|
Re: hash sort
by johngg (Canon) on May 31, 2017 at 17:45 UTC | |
|
Re: hash sort
by thanos1983 (Parson) on May 31, 2017 at 15:34 UTC | |
by Anonymous Monk on May 31, 2017 at 15:54 UTC | |
by thanos1983 (Parson) on May 31, 2017 at 20:24 UTC | |
|
Re: hash sort
by tybalt89 (Monsignor) on May 31, 2017 at 16:46 UTC | |
by Anonymous Monk on May 31, 2017 at 17:34 UTC | |
by haukex (Archbishop) on May 31, 2017 at 18:22 UTC | |
by AnomalousMonk (Archbishop) on May 31, 2017 at 20:56 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |