Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Answer: How do I do a natural sort on an array?

( #68394=categorized answer: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub byfile {
      my @a = split /(\d+)/, $a;
    ...
      }
      $res;
    }
    
  2. or download this
    53 7 119 53red
    red5 red6 red7 red67 red6.jpg red12.jpg
    green4.jpg
    blue2.jpg blue1000.jpg blue2.jpg58
    
  3. or download this
    7
    53
    ...
    red7
    red12.jpg
    red67
    
  4. or download this
     while (defined (my $A = shift @a) and defined (my $B = shift @b)) {
       $res = ($A =~ /\d/) ? $A <=> $B : $A cmp $B;
       return $res if $res;
     }
     return defined $A ? -1 : 1;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2014-08-20 21:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (124 votes), past polls