in reply to sorting array of hashes using multiple keys conditionally
Not two sorts. One sort with a properly crafted compare function.
@a = sort { $a->{key1} <=> $b->{key1} || $a->{key2} <=> $b->{key2} } @a;
I've been reading up on Schwartzian Transforms, which I'm still not sure are applicable here.
It's not. It's used to minimize the cost of expensive compares (e.g. if I/O is done) when sorting long lists.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting array of hashes using multiple keys conditionally
by Marshall (Canon) on Dec 05, 2009 at 21:35 UTC | |
by jwkrahn (Abbot) on Dec 05, 2009 at 22:41 UTC | |
|
Re^2: sorting array of hashes using multiple keys conditionally
by mabman2 (Novice) on Dec 06, 2009 at 06:28 UTC |