Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Sorting multiple arrays

by Codon (Friar)
on Sep 13, 2005 at 15:49 UTC ( #491607=note: print w/ replies, xml ) Need Help??


in reply to Re: Sorting multiple arrays
in thread Sorting multiple arrays

This doesn't sort @array_b. The OP could then just numeric sort @array_b in a separate operation.

Ivan Heffner
Sr. Software Engineer, DAS Lead
WhitePages.com, Inc.


Comment on Re^2: Sorting multiple arrays
Select or Download Code
Replies are listed 'Best First'.
Re^3: Sorting multiple arrays
by merlyn (Sage) on Sep 13, 2005 at 15:51 UTC
    Maybe I skimmed too fast, but I thought the sorting of array_b was only a logical sort to show how array_a needed to be reordered.

    If that's not the case, saving the indicies and using them twice would do the trick:

    my @indicies = sort { $array_b[$a] <=> $array_b[$b] } 0..$#array_b; my @sorted_a = @array_a[@indicies]; my @sorted_b = @array_b[@indicies];

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2015-08-29 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (344 votes), past polls