Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How can I access object data in a user defined sort cmp function?

by LanX (Sage)
on Jan 28, 2015 at 17:12 UTC ( #1114788=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %h    = %{$self->{hash_ref}};
    my @keys = sort { $h{$a} <=> $h{$b} } keys %h;
    
  2. or download this
      DB<100> $self={
               hash_ref=>{item1=>'value1',item2=>'value2'}
    ...
    
      DB<103> @keys=sort {$h{$a}<=>$h{$b}} keys %h;
     => ("item1", "item2")
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2022-05-23 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?