You want to sort a list of key pairs, so you have to start by building a list of key pairs. A reference to an array is the obvious answer. Once you've figured this out, everything is straight forward.
Building the list of keys:
my @unsorted_keys;
for my $k1 (keys(%$VAR1)) {
for my $k2 (keys(%{ $VAR1->{$k1} })) {
push @unsorted_keys, [ $k1, $k2 ];
}
}
Sorting those key:
my @sorted_keys = sort {
my ($a_k1, $a_k2) = @$a;
my ($b_k1, $b_k2) = @$b;
( my $a_pc = $VAR1->{$a_k1}{$a_k2}{keyc} ) =~ s/%//;
( my $b_pc = $VAR1->{$b_k1}{$b_k2}{keyc} ) =~ s/%//;
$a_pc <=> $b_pc
} @unsorted_keys;
Iterating over the sorted keys:
for (@sorted_keys) {
my ($k1, $k2) = @$_;
my $hash = $VAR1->{$k1}{$k2};
... do stuff with %$hash ...
}