Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: sorting a hash by keys, according to preference

by Tanktalus (Canon)
on Apr 13, 2005 at 03:57 UTC ( #447254=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    .4  .6  .1
    .3  .5  .1
    .0  .2  .1
    .5  .7  .1
    
  2. or download this
    my @keys = qw(start stop step);
    for my $type (@keys) {
      print $point->{$type}, "\t";
    }
    
  3. or download this
    my @keys = qw(start stop step);
    for my $type (@keys) {
      next unless exists $point->{$type};
      print $point->{$type}, "\t";
    }
    
  4. or download this
    my %weights = ( start => 10, stop => 20, step => 30 );
    for my $type ( sort { $weights{$a} <=> $weights{$b} } keys %$point ) {
      print $point->{$type}, "\t";
    }
    
  5. or download this
    my %weights = do { my $i = 0; map { $_ => $i++ } qw(start stop step ot
    +her stuff in order here) };
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://447254]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2020-12-04 21:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (62 votes). Check out past polls.

    Notices?