go ahead... be a heretic | |
PerlMonks |
Complex Sort - using varying numbers of parametersby George_Sherston (Vicar) |
on Jul 04, 2002 at 12:08 UTC ( [id://179436]=perlquestion: print w/replies, xml ) | Need Help?? |
George_Sherston has asked for the wisdom of the Perl Monks concerning the following question:
I have an array of hashes, @Tree. One of the elements in each hash, Path is itself an array of digits. For each element in @Tree, $_->{Path} can have from one to five (at present - could be even more) elements. And I need to sort @Tree so that it's sorted first by $_->{Path}->[0], then by $_->{Path}->[1] and so on.
In case that doesn't make any sense, I've done ... for before and after, to show what I'm trying to achieve: BEFORE AFTER: I've tried lots of different variations on ... none of which worked. In the end I gave up in disgust and did ... which works, but is UGLY and probably slow and fattening. I'd really love to see a more elegant solution, if some monk can suggest one. Now, I got this result with the following rather clunky method: § George Sherston 2002-07-06 Edit by Corion: Added readmore tag
Back to
Seekers of Perl Wisdom
|
|