in reply to RE: Simple sorting by another parallel array
in thread Simple sorting by another parallel array

You mean this?

my @sorted_names= @names[ my @idx= sort {$ages[$a]<=>$ages[$b]} 0..$#ages ]; my @sorted_ages= @ages[@idx];

This is much more efficient than sorting by age all over again.

Update: Fixed my typo.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
RE: RE: RE: Simple sorting by another parallel array
by extremely (Priest) on Sep 25, 2000 at 00:11 UTC

    Nice! Cept you typo'd "args" should be "ages". Very nice tho. That is a fine use of array slicing...

    /me sticks idea into toolbox for later =)

    --
    $you = new YOU;
    honk() if $you->love(perl)