http://qs1969.pair.com?node_id=223046

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a list of files:
file1
file2
...
file10
...
file20
...

The list can contain any number of file names up to about 1000. I have these names stored in a hash, and use the following code to print the file names:
foreach my $file (sort {$a cmp $b} keys %hash) { print "$key \n"; }
problem is the the filenames print like this:
file1
file10
file11
file2
file20
file3

How do I sort them based on counting order? I don't have access to install any modules that are not already installed on the system, so please don't suggest a module.

Thanks in Advance.