The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 -->
  #1 (permalink)  
Old 10-09-2008
zx1106 zx1106 is offline
Registered User
  
 

Join Date: Mar 2008
Location: U.S.
Posts: 21
[B]Perl sort quick question[/B]

I've done a quick Google about this, but could not find the answer I want.

Say, there is an array like this:
@A = qw(cd1 a1 ef a2 hij a12 b2 b4 b22);

I want to sort the array in the first order:
@sorted = qw(a1 a12 a2 b2 b22 b4 cd1 ef hij);

And second order:
@sorted = qw(a1 a2 a12 b2 b4 b22 cd1 ef hij);

Is there a way to do this in Perl without using modules?

Thanks a lot!

Last edited by zx1106; 10-09-2008 at 12:44 PM..