http://qs321.pair.com?node_id=385922


in reply to Sort array1 according to sorting of array2

@arr1=@arr1[sort{$arr2[$a]<=>$arr2[$b]}0..$#arr2];

Replies are listed 'Best First'.
Re^2: Sort array1 according to sorting of array2
by hv (Prior) on Aug 26, 2004 at 11:09 UTC

    Yup, this is how I'd do it (maybe with a touch more whitespace). I'd expect this also to be more efficient than any approach splitting the numbers out of @arr1 again, though not necessarily better than switching to different ways of structuring the data.

    Hugo