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:
sorting

 



wickedxter
User

May 31, 2001, 3:41 PM

Post #1 of 3 (984 views)
sorting Can't Post

i've got a script that's sorting numbers, but it's not sorting dubble digits(EX: 69) it's just puting it at the top.



AICapone
Deleted

May 31, 2001, 4:04 PM

Post #2 of 3 (981 views)
Re: sorting [In reply to] Can't Post

hmmm... no offense but I wonder how do you sort them? :))
hey, try something like this

#!/usr/bin/perl
print "Content-type: text/html\n\n";
@unsorted=qw(4 5 98 23 54 56 12 3 74 8 2 .3 59 12 1 0 2 3 6 8 102);
@sorted=sort {$b <=> $a} @unsorted;
print @sorted;
if you want them to go from greatest to lowest or

...
@sorted=sort {$a <=> $b} @unsorted;
...

to go from lowest to largest

well, that should do it, but feel free to read perldoc -f sort for more details
cya

-----------------------------------------------------------
What is difficlut takes time, what is impossible takes a little longer


wickedxter
User

May 31, 2001, 6:26 PM

Post #3 of 3 (978 views)
Re: sorting [In reply to] Can't Post

great.. thx a bunch...


 
 


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

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