Help for this page

Select Code to Download


  1. or download this
    my @values = @hash{ sort { $a <=> $b } keys %hash };
    
  2. or download this
    %hash = ();
    @hash{ 0..@values-1 } = @values;
    
  3. or download this
    @hash{ keys(%hash), 0..keys(%hash)-1 } = ((undef) x keys(%hash), @hash
    +{ sort { $a <=> $b } keys %hash });
    delete @hash{ grep !defined $hash{$_}, keys %hash };
    
  4. or download this
    @hash{ 0..keys(%hash)-1 } = delete @hash{ sort { $a <=> $b } keys %has
    +h };