my $target = \ $tmp{$record->{name}}; $$target->{name} = $record->{name}; $$target->{_order} //= $order++; delete $_->{_order} for @new_sorted_data;