I'm sorry that just be clear you want the non-directory first,then simply change the codes to:
my @items = map { $_->[0] } sort { $a->[1] <=> $b->[1] or $a->[0] cmp $b->[0] } map { -d $_ ? [$_,1] : [$_,0] } readdir DIR; 2007/4/27, Jeff Pang <[EMAIL PROTECTED]>:
2007/4/27, Nigel Peck <[EMAIL PROTECTED]>: > > 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. Hello, I've tested, this could work for you. my @items = map { $_->[0] } sort { $a->[1] <=> $b->[1] or $a->[0] cmp $b->[0] } map { -d $_ ? [$_,0] : [$_,1] } readdir DIR; -- Chinese Practical Mod_perl book online http://home.arcor.de/jeffpang/mod_perl/
-- Chinese Practical Mod_perl book online http://home.arcor.de/jeffpang/mod_perl/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/