No need for "$_". This line should be:
print join (',' , sort {$a <=> $b} keys %$h),"\n";
While $_viewed as the default iterator in loops forand foreach(see perlvar ), you have already assigned the iterator variable as $num.
Here's how to use it $_on one line:
print join(',', sort { $a <=> $b } keys %{$hash{$_}}),"\n" foreach keys %hash;
On a side note ...
sort , , '10' '2'. , (?), { $a <=> $b }.