in reply to Is this sort of possible
If you don't want to use the transform, you can always sort multiple arrays by the order of one:
my @ids; my @titles; my @dates; foreach $line (@FILE) { my($id_number, $title, $date) = split(/\|/,$line); push (@ids, $id_number); push (@titles, $title); push (@dates, $date); } my @sorted = sort { $titles[$a] cmp $titles[$b] } (0 .. $#titles); @ids = @ids[@sorted]; @titles = @titles[@sorted]; @dates = @dates[@sorted];
Not quite as elegant looking as the Schwartzian Transform, but it will do the trick. Also, this will be easier to work with if you need to modify $title, $id_number, or $date in the foreach loop.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
It is possible
by Cosmos (Initiate) on Jan 01, 2002 at 17:07 UTC |