[ale] sort using perl

Benjamin Dixon beatle at arches.uga.edu
Tue Dec 18 10:45:19 EST 2001



This seems to work for me:

@unsorted = <your list of strings>;

@sorted = sort { $a[2] cmp $b[2] } @unsorted;

Ben

On Tue, 18 Dec 2001, Cadet Hacker wrote:

> Hello,
> Does anybody know a quick and dirty way to sort by the third letter in a
> string using perl or korn, so if the list is
> 
> xxb234
> xxc123
> xxa291
> 
> it will come out
> 
> xxa291
> xxb234
> xxc123
> 
> 
> The third letter will always be a letter. TIA! basically the third letter
> is the first letter of the last name, hense the sort rule. Thanks
> 
> -- 
> --cade
> =========================
> On Linux vs Windows --
> Remember amateurs built the ark - professionals built the Titanic
> =========================
> 
> 
> ---
> This message has been sent through the ALE general discussion list.
> See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
> sent to listmaster at ale dot org.
> 

Today's Random Quote--------------------------------------

 Most people don't need a great deal of love nearly so much as
they need a steady supply.

-----------------------------------------------------------


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list