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.
In reply to Re: sorting array of hashes using multiple keys conditionally
by ikegami
in thread sorting array of hashes using multiple keys conditionally
by mabman2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |