in reply to Sorting hash on deep value
Do you mean something like:
$Records{'1'}{'Meta'}{'Name'} = 'Alice'; $Records{'1'}{'Packages'}{'PackageID'} = 1; $Records{'2'}{'Meta'}{'Name'} = 'Bob'; $Records{'2'}{'Packages'}{'PackageID'} = 1;
If so, you can get a list of customer ids sorted by name like this:
my @sorted = map $_->[0], # transform pairs back into + ids sort { $a->[1] cmp $b->[1] } # sort by name map [ $_, $Records{$_}{Meta}{Name} ], # transform into [id, name] + pairs keys %Records; # list of customer ids
If that's not your data structure, could you please post a small example of your data?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting hash on deep value
by Anonymous Monk on Nov 10, 2019 at 16:27 UTC |