in reply to Re: Complicated, multi-level array sorting
in thread Complicated, multi-level array sorting

That actually won't work for classic Perl, because the sort is not guaranteed stable. That is, when the sort comparison returns 0, the sort operator is free to place the left item before the right, or vice versa. So your third sort might wipe out the second sort, and the second sort might have already wiped out the first sort.

You need to do the comparison all at once:

@output = sort { $a->{cat} cmp $b->{cat} or $a->{name} cmp $b->{name} or $a->{rating} <=> $b->{rating} # rating looks numeric } @input;
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.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.