mabman2 has asked for the wisdom of the Perl Monks concerning the following question:
One piece of my latest program populates an array of hashes, each hash has multiple key/value pairs.
What I want to do after populating the array is:
- sort the array based on the value of 1 key
- if 2 or more elements have the same value of that key (values will be numeric), sort just those elements by the value of a 2nd key (without altering the sort order of the other elements in the array)
Sorting the array by the value of key is easy enough, but how to sort only some elements conditionally has me all kerfuffled. I've been reading up on Schwartzian Transforms, which I'm still not sure are applicable here.
Any advice (preferably with code samples) would be greatly appreciated.
Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sorting array of hashes using multiple keys conditionally
by ikegami (Patriarch) on Dec 05, 2009 at 17:54 UTC | |
by Marshall (Canon) on Dec 05, 2009 at 21:35 UTC | |
by jwkrahn (Abbot) on Dec 05, 2009 at 22:41 UTC | |
by mabman2 (Novice) on Dec 06, 2009 at 06:28 UTC | |
|
Re: sorting array of hashes using multiple keys conditionally
by GrandFather (Saint) on Dec 05, 2009 at 23:06 UTC |