Hi,

I have a list containing the names of all items in a directory. I want to sort it by non-directories first and then directories, with a secondary sort in alphabetical order.

I currently have:

--------------------------------
my @items = sort {
        
        my $a_path = $args->{directory_from} . '\\' . $a;
        my $b_path = $args->{directory_from} . '\\' . $b;
        
        ( -d $a_path ) ? 1 : 0;
        
} readdir $directory;
--------------------------------

which gets me the non-directories first and directories after but not in alphabetical order.

I don't want to rely on the alphabetical ordering from the readdir as I believe that Perl's sort does not guarantee to maintain ordering in future releases?

Can't get my head round this, please help! :)

Cheers,
Nigel

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to