Sorting values of hash in ascending order using Perl

I want to sort values of a hash in ascending order.

my %records;

for my $value (sort values %records){print $value,"\n";}

When I use the above code I get values in this order: 1,10,11,2,3,4,5,6,7,8,9. But, I need values in my output in this order: 1,2,3,4,5,6,7,8,9,10,11.

Can Someone help me in this?

Thanks in advance

Sorting in Perl can be tricky, but this is a classic: google "perl sort hash by value".

foreach $key (sort {$records{$a} <=> $records{$b}}
              keys %records) {
    print "$key\t$records{$key}\n";
}