Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: sorting hashesby AnomalousMonk (Archbishop) |
on Mar 24, 2009 at 19:45 UTC ( [id://752947]=note: print w/replies, xml ) | Need Help?? |
I am not sure I understand what you require, but if it is "How might I sort the keys or values of a hash by the index in the @cols array of the value of the hash element", then it is necessary to first make a mapping of the elements of the @cols array to their indices: another hash. Once you have the element-to-index mapping of the array, it is straightforward to sort the keys or values of the original hash by these indices.
The preceding assumes that every value of the hash is an element of the array; it would be wise to validate this assumption.
In Section
Seekers of Perl Wisdom
|
|