in reply to sorting based on a list
If you are really going to sort by the first letter only
in a special order you might try it with this:
--
use signature; signature(" So long\nAlfie");
The first will compare the first letter only, the later will compare if the first letter is equal.my $sortstr = join('', @list); my @sorted_list = sort { index($sortstr,substr($a,0,1)) <=> index($sortstr,substr($b,0,1)) || $a <=> $b } @list2;
--
use signature; signature(" So long\nAlfie");
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: sorting based on a list
by ChemBoy (Priest) on May 09, 2001 at 19:05 UTC |
In Section
Seekers of Perl Wisdom