in reply to Indexing a data structure

What you are looking for is to store the rank of elements in @a in @b. (I think it was Randal who came up with the following idea first) -

use Data::Dumper; $a[1]{total} = 10; $a[2]{total} = 50; $a[3]{total} = 40; $a[4]{total} = 20; $a[5]{total} = 30; @b[sort{$a[$b]{total}<=>$a[$a]{total}}1..$#a] = 1..$#a; print Dumper(\@b);
And the output is -

$VAR1 = [ undef, # this is ignored because index begins at 1 5, 1, 2, 4, 3 ];