in reply to sorting hash of array of hashes by value
But you can keep sorted arrays of keys or values.
Your wish to keep the "path"s of a HoAoH sorted is a strong indication for me that you might wanna check the multi-dim hashes we inherited from Perl4.
Like this you could flatten your data to a 1-dim hash
$hash{$key0,$idx0,$key1}=<some floating point value>
and keep an array of sorted @keys .
Looks far simpler for me! (effectively it's using your concat approach w/o the overhead of the origanal HoAoH)
If you need this more often you might wanna check on tiehash solutions on CPAN to allow sorted hashes by encapsulating the sorted @keys .
HTH =)
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
fixed syntax error by 's/;/,/'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting hash of array of hashes by value
by LanX (Saint) on Aug 26, 2014 at 21:25 UTC |