CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Easy One: Sort Question

 



gregarios
stranger

Jan 30, 2001, 3:34 PM

Post #1 of 3 (374 views)
Easy One: Sort Question Can't Post

How can I sort an array of strings, lets say @strings, in case insensitive alphabetic/numeric order, and have it totally ignore spaces, hyphens, etc that may be in the string?



japhy
Enthusiast

Jan 30, 2001, 4:20 PM

Post #2 of 3 (372 views)
Re: Easy One: Sort Question [In reply to] Can't Post

You want to use a schwartzian transform, methinks:


Code
@sorted = 
map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { (my $copy = $_) =~ tr/a-zA-Z0-9//cd; [ $_, $copy ] }
@original;

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author


gregarios
stranger

Jan 30, 2001, 4:33 PM

Post #3 of 3 (370 views)
Re: Easy One: Sort Question [In reply to] Can't Post

Thanks! :-)


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives