GuiPerl has asked for the wisdom of the Perl Monks concerning the following question:
I have tried the following:my $Rec = { ORG_LEVEL_DESCRIP=>$rec->[10], GRADE=>strip_hyphen($rec->[15]), POSITION=>$rec->[2], NAME=>invert_name($rec->[16]), AGE=>convert_date_to_age(trim($rec->[17])), DATE_OF_BIRTH=>date_of_birth_cleansed($rec->[17 +]), COUNTRY=>$rec->[19], }; push @{$AG{$rec->[10]}},$Rec;
foreach my $p ( sort { $$b{GRADE} <=> $$a{GRADE}} @{$AG}) { ................. }
I get the the following output: D1 P5 P2 P3
Instead, I would like to output by letter first and then by number as illustrated below: D1 P5 P5 P4 P4 P3 P3 P2 P1 etc.
In other words, I would like to sort by this value GRADE=>strip_hyphen($rec->15) where the P5, P4, etc. are stored.Any ideas.SAMPLE DATA P5 , Health Officer, M. Famzo, France, 1/1/1957 P5 , Health Officer,S. Fey, United States, 4/16/1960 P2 , Health Officer, F. Ban, France, 10/5/1966 P4 , Health Officer, J. Pino, Germany, 9/19/1948 P3 , Health Officer,G. Brown, Greece, 5/15/1974 D1 , Health Officer, J. Hill, Syria, 2/10/1962
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting a Hash
by Eily (Monsignor) on Sep 03, 2014 at 15:03 UTC | |
|
Re: Sorting a Hash
by LanX (Saint) on Sep 03, 2014 at 13:52 UTC | |
|
Re: Sorting a Hash
by GuiPerl (Acolyte) on Sep 04, 2014 at 09:35 UTC |