Help for this page

Select Code to Download


  1. or download this
    my @sorted_keys =
      sort { extract( $hash{ $a } ) <=> extract( $hash{ $b } ) } keys %has
    +h;
    ...
    for my $key ( @sorted_keys ) {
      # whatever
    }
    
  2. or download this
    my @sorted_keys =
      sort { $hash{ $a } cmp $hash{ $b } } keys %hash;
    ...
    for my $key ( @sorted_keys ) {
      # whatever
    }
    
  3. or download this
    my @sorted_keys =
      map  { $_->[0] }
      sort { $a->[1] cmp $b->[1] }
      map  { [ $_, extract( $hash{ $_ } ) ] }
      keys %hash;
    
  4. or download this
    my @sorted = sort { f($a) cmp f($b) } @unsorted;
    
  5. or download this
    my @sorted = sort { f($a) <=> f($b) } @unsorted;
    
  6. or download this
    sub f {
      my $key = shift;
      return $hash{ $key };
    }