in reply to sorting based on a list
my @indicies = sort { $list[$a] cmp $list[$b] } 0..$#list; my @rearranged = @list2[@indicies];
-- Randal L. Schwartz, Perl hacker
There. Make a sorted @list2 be disordered in the same way that @list is.my @indicies = sort { $list[$a] cmp $list[$b] } 0..$#list; my @rearranged; @rearranged[@indicies] = sort @list2;
Also see my other solution.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: sorting based on a list
by suaveant (Parson) on May 09, 2001 at 18:43 UTC |