The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 10-10-2008
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
Second order which appears to be first sort by alpha then digit:

Code:
my @A = qw(cd1 a1 ef a2 hij a12 b2 b4 b22);

my @sorted = map{$_->[2]}
          sort{$a->[0] cmp $b->[0] || $a->[1] <=> $b->[1]}
          map{/([a-z]*)(\d*)/;[$1,$2,$_]} @A;

print "$_\n" for @sorted;
Google "Schwartzian Transform" if interested in the cached key sort technique.