in reply to Re: Complicated, multi-level array sorting
in thread Complicated, multi-level array sorting
You need to do the comparison all at once:
P.S. Modern Perl has a stable sort by default, but may be influenced at a distance to be an unstable sort, so it's best to pretend that this isn't so unless you control the entire program and can also ensure that your code will never run on older Perl versions.@output = sort { $a->{cat} cmp $b->{cat} or $a->{name} cmp $b->{name} or $a->{rating} <=> $b->{rating} # rating looks numeric } @input;
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|