Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I am working with hash of arrays that need to be sorted. I would like the order to be driven by the highest Score value per entry key and then sorted within each key based on Score. It would be easy if not for the Location arguments that I would like to mirror the Score sorting. Example;my %entry; push @{$entry{'BLA'}{Score}}, 5; push @{$entry{'BLA'}{Location}}, '1-10'; push @{$entry{'TRA'}{Score}}, 15; push @{$entry{'TRA'}{Location}}, '7-15'; push @{$entry{'TRA'}{Score}}, 23; push @{$entry{'TRA'}{Location}}, '4-19'; push @{$entry{'TRA'}{Score}}, 2; push @{$entry{'TRA'}{Location}}, '78-120'; push @{$entry{'BLA'}{Score}}, 10; push @{$entry{'BLA'}{Location}}, '2-10'; Output; TRA 23 4-19 TRA 15 7-15 TRA 2 78-120 BLA 10 2-10 BLA 5 1-10
Any ideas? Speed is a factor and for various reasons within the code I have to stick with this particular data structure. I presume once it's sorted and I don't add anything it will stay sorted? Thanks for help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Advance Sorting
by tangent (Parson) on Jun 03, 2014 at 17:24 UTC | |
by Anonymous Monk on Jun 03, 2014 at 17:28 UTC | |
|
Re: Advance Sorting
by LanX (Saint) on Jun 03, 2014 at 16:35 UTC | |
by Anonymous Monk on Jun 03, 2014 at 16:46 UTC | |
by LanX (Saint) on Jun 03, 2014 at 16:54 UTC | |
by Anonymous Monk on Jun 03, 2014 at 17:03 UTC | |
by LanX (Saint) on Jun 03, 2014 at 17:09 UTC | |
|
Re: Advance Sorting
by poj (Abbot) on Jun 03, 2014 at 19:40 UTC | |
by Anonymous Monk on Jun 03, 2014 at 19:42 UTC | |
|
Re: Advance Sorting
by AnomalousMonk (Archbishop) on Jun 04, 2014 at 00:05 UTC | |
by Anonymous Monk on Jun 04, 2014 at 08:58 UTC |