@output = sort { $a->{cat} cmp $b->{cat} or $a->{name} cmp $b->{name} or $a->{rating} <=> $b->{rating} # rating looks numeric } @input;