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); #### $VAR1 = [ undef, # this is ignored because index begins at 1 5, 1, 2, 4, 3 ];