in reply to sorting multiple arrays on the criteria of one array
use strict; my @lA=reverse(1..9); my @lB=1..9; my @lC="a".."i"; sub trimult{ my ($l1,$l2,$l3)= @_; #list refs my @l; #temp list push @l,[$$l1[$_],$$l2[$_],$$l3[$_]] foreach (0..(scalar(@{$l1})-1)) +; #an array of each 3-uplet @l=map {$_->[0]} sort{$a->[1] <=> $b->[1]} map {[$_,$_->[0]]} @l; # S.Transform: sorting according to the first + elements (ie array l1) my $t=0; # I'm sure there is a perlvar that equals 0 ($| maybe?), bu +t this aint an obfu contest :) ($$l1[$t],$$l2[$t],$$l3[$t++])=@{$_} foreach(@l); # so @l is an array of array. So I can cast it's elements type as arr +ays @{likethis} and the assign them to my vars in a list context. } #end of procedure print "@lA, @lB, @lC\n"; #print &trimult (\@lA,\@lB,\@lC);#sort print "@lA, @lB, @lC\n"; #print and enjoy.
|
|---|