Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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 making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-01-27 03:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My top resolution in 2015 is:

















    Results (197 votes), past polls