ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-users
perl-win32-users
Re: How to sort these elements
by Chris Wagner other posts by this author
Oct 26 2005 7:18AM messages near this date
view in the new Beta List Site
How to sort these elements | RE: How to sort these elements
U'll need a two stage sort.  Once to get the dirs in ascii order and then
again on each group to get the numeric sort.  Read perldoc -f sort.

foreach $i (@list) {
        ($dir, $file) = $i =~ m/^(.+)\/(.+)$/;
        push @{$hash{$dir}}, $file;
}
foreach $key (sort %hash) {
        @j = sort {$a <=>  $b}  @{$hash{$key}};
        foreach $k (@j) {
                print $key, "/", $k, "\n";
        }
}
       

At 04:20 PM 10/26/2005 +0530, Maxmelbin Neson (RBIN/EDM3) wrote:
> @b= sort(@a);
> How do I sort it so that I get the following correct output as follows
>  /view/test.max2kor1/vobs/maxvob/max.c@@/main/tmp_maxtest1/7 
>  /view/test.max2kor1/vobs/maxvob/max.c@@/main/tmp_maxtest1/17 
>  /view/test.max2kor1/vobs/maxvob/satish.c@@/main/tmp_maxtest1/1
> /view/test.max2kor1/vobs/maxvob/satish.c@@/main/tmp_maxtest1/2
> /view/test.max2kor1/vobs/maxvob/satish.c@@/main/tmp_maxtest1/4 
> /view/test.max2kor1/vobs/maxvob/satish.c@@/main/tmp_maxtest1/12 
>  /view/test.max2kor1/vobs/maxvob/satish.c@@/main/tmp_maxtest1/102 


--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 > =--
"...ne cede malis"

00000100

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Maxmelbin Neson
Chris Wagner
Joe Discenza

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved