title: How can I sort a list of strings by numbers in them?
body: <p>An easy one no doubt for you...</p>
  
  <p>I have a list of filenames which are like so;</p>
  
  <pre><code>fw_d.log.1.gz  
  through  
  fw_d.log.300.gz  
  </code></pre>
  
  <p>When i use this below code block, it almost sorts it the way i want, but not quite.</p>
  
  <pre><code>#!/usr/bin/perl -w
  my $basedir = "/var/log";
  my @verdir = qw(fw_d);
  my $fulldir;
  my $configs;
  my $combidir;
  
  foreach $combidir (@verdir) {
      $fulldir = "$basedir/$combidir";
      opendir (DIR, $fulldir);
      my @files = grep { $_ ne '.' &amp;&amp; $_ ne '..' &amp;&amp; $_ ne 'CVS' readdir DIR;
      closedir (DIR);
      @files1 = sort {$a cmp $b}(@files);
      foreach my $configs (@files1) {
          print "Checking $configs\n";
          system("less $basedir/$combidir/$configs | grep \'.* Group = , Username = .* autheauthenticated.\' &gt;&gt; output.log" );
      }
  }
  </code></pre>
  
  <p>here is a snippet output</p>
  
  <pre><code>Checking fw_d.log  
  Checking fw_d.log.1.gz  
  Checking fw_d.log.10.gz  
  Checking fw_d.log.100.gz  
  Checking fw_d.log.101.gz  
  Checking fw_d.log.102.gz  
  </code></pre>
  
  <p>As you can see, it almost sorts it how i was hoping....  Does anyone have any suggestions, on either reading, or a code snippet i can use?</p>
  
  <p>Thanks in advance.<br>
  Steve.</p>