Re: Sorting the items in a directory

2007-04-27 Thread Nigel Peck
Thanks Jeff, thanks Rob. I used your solution Jeff and it's working a treat. Cheers, Nigel Rob Dixon wrote: Nigel Peck wrote: 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 alph

Re: Sorting the items in a directory

2007-04-27 Thread John W. Krahn
Nigel Peck wrote: > > Hi, Hello, > 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 { >

Re: Sorting the items in a directory

2007-04-27 Thread Rob Dixon
Nigel Peck wrote: 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 = $a

Re: Sorting the items in a directory

2007-04-27 Thread Jeff Pang
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,

Re: Sorting the items in a directory

2007-04-27 Thread Jeff Pang
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]

Sorting the items in a directory

2007-04-27 Thread Nigel Peck
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->{direc