I guess it depends upon whether you feel the intermediate ordering or the final ordering specified is the crux of what the OP is trying to achieve?
use strict; my @vector = qw( 27 32 46 5 102 76 ); my @order = sort{ $vector[ $a ] <=> $vector[ $b ] } 0 .. $#vector; my $i = 1; my @order_it; foreach (@order) { $order_it[$_] = $i++; } print join(' ',@order_it),"\n"; print "@vector[ @order_it ]\n"; __END__ P:\test>junk 2 3 4 1 6 5 Use of uninitialized value in join or string at P:\test\junk.pl line 1 +1. 46 5 102 32 76
In reply to Re^2: Getting the order of an array
by BrowserUk
in thread Getting the order of an array
by srdst13
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |