for $hash (values %ManagerInCharge) { $i = 0; %$hash = (map {;++$i => $_} map $hash->{$_}, sort {$a <=> $b} keys %$hash); }