There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hashes can't be sorted b/c they have no order.
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 ☆☆☆☆ :)
editfixed syntax error by 's/;/,/' In reply to Re: sorting hash of array of hashes by value
by LanX
|
|