K_Edw has asked for the wisdom of the Perl Monks concerning the following question:
I'm currently creating keys by joining a number of input .txt file fields:
my @F = split("\t", $_); $freq{join "\t", @F[0..1],@F[3..4]}++;
However the data is of mixed alphanumeric format, an example key would be:
1 12301 A BWhen it comes to printing and handling the hash contents, I want to be able to sort the keys numerically - by the first number and then by the second, so that it would print like this:
1 12301 A B 1 12310 A B 2 4501 A B 2 15410 A B
And so forth.
Is this at all possible with the way the keys are currently created? Would it simply be easier to use a multidimensional hash and then nested loops to try and handle accessing the elements?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting a mixed-format hash key
by hippo (Archbishop) on Aug 11, 2016 at 12:50 UTC | |
|
Re: Sorting a hash that has mixed-format keys
by planetscape (Chancellor) on Aug 11, 2016 at 13:37 UTC | |
|
Re: Sorting a hash that has mixed-format keys
by AnomalousMonk (Archbishop) on Aug 11, 2016 at 14:39 UTC | |
|
Re: Sorting a hash that has mixed-format keys
by perldigious (Priest) on Aug 11, 2016 at 13:05 UTC | |
|
Re: Sorting a hash that has mixed-format keys
by K_Edw (Beadle) on Aug 11, 2016 at 14:20 UTC |