Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Sort array1 according to sorting of array2

by I0 (Priest)
on Aug 26, 2004 at 05:50 UTC ( #385922=note: print w/ replies, xml ) Need Help??


in reply to Sort array1 according to sorting of array2

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


Comment on Re: Sort array1 according to sorting of array2
Download Code
Replies are listed 'Best First'.
Re^2: Sort array1 according to sorting of array2
by hv (Parson) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://385922]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2015-07-30 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls