in reply to Getting the order of an array

Another way of getting close to the OP's desired results:
UPDATE:Finally figured what the OP was trying for:
- he needs both ORDER and RANK.
my @vector = qw( 27 32 46 5 102 76 ); my @order = map {$_+1} sort{ $vector[ $a ] <=> $vector[ $b ] } 0 .. $#vector; my ($r,@rank); $rank[$_ - 1]= ++$r for @order; unshift @vector,undef; print qq(@rank\n@vector[@order]\n) __Output__ 2 3 4 1 6 5 5 27 32 46 76 102
The OP's definition of the sequence of @order was probably wrong.
The code looks funky because the OP seems to want a lower-bound of 1 instead of zero, for the @vector array.

     "There are only two truly infinite things. The universe and stupidity, and I'm not too sure about the universe"- Albert Einstein