A
alexxx.magni
Hi everybody,
I need some hints on how to setup the sort function in a couple of
cases that happened to me recently
<disclaimer>I already did perldoc -f sort, yet I found mainly
discussed numerical/alphabetical cases</disclaimer>
The two sort problems I had - neither of which I was able to solve -
are the following:
1) given in @a a list of files/directories (e.g. returned by
File::Find), sort it directories first, then symlinks, then common
files.
The nearer I came was:
@a=sort {my $x= -d $a; my $y= -d $b; return $x
<=> $y} @a;
but it doesnt work.
2) sort @a, based on the existence/non-existence of the hash value
$c{$a}, where $a's are the elements of @a.
Both the problems are related to my difficulty of translating them in
some kind of comparison between two generic elements $a vs $b, as in
the typical $a<=>$b
Any hint is welcome!
Alessandro Magni
I need some hints on how to setup the sort function in a couple of
cases that happened to me recently
<disclaimer>I already did perldoc -f sort, yet I found mainly
discussed numerical/alphabetical cases</disclaimer>
The two sort problems I had - neither of which I was able to solve -
are the following:
1) given in @a a list of files/directories (e.g. returned by
File::Find), sort it directories first, then symlinks, then common
files.
The nearer I came was:
@a=sort {my $x= -d $a; my $y= -d $b; return $x
<=> $y} @a;
but it doesnt work.
2) sort @a, based on the existence/non-existence of the hash value
$c{$a}, where $a's are the elements of @a.
Both the problems are related to my difficulty of translating them in
some kind of comparison between two generic elements $a vs $b, as in
the typical $a<=>$b
Any hint is welcome!
Alessandro Magni