my @b = map { $_->[1] } sort { $b->[0] <=> $a->[0] } map { [ $a[ $_ ]->{total}, $_ ] } 0..$#a;