in reply to Getting the order of an array
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
"There are only two truly infinite things. The universe and stupidity, and I'm not too sure about the universe"- Albert Einstein
|
|---|