in reply to sorting based on a list
Here's one suggestion using hash slices:
#!/usr/bin/perl -w use strict; my @list = qw(a z b y c x); my @list2 = qw(zulu charlie xray yankee bravo alpha); my %hash; @hash{@list} = @list2; my @sorted = @hash{sort @list}; print "@sorted\n";
Update: OK. Misunderstood the question. In that case it's:
@hash{sort @list} = sort @list2; my @sorted = @hash{@list};
but merlyn's solution is better :(
--
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: sorting based on a list
by suaveant (Parson) on May 09, 2001 at 18:27 UTC | |
|
Re: Re: sorting based on a list
by Chady (Priest) on May 09, 2001 at 18:19 UTC | |
by davorg (Chancellor) on May 09, 2001 at 18:52 UTC |