Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Custom, Reusable Sort Subroutine for Hashes?

by Corion (Patriarch)
on Aug 30, 2017 at 11:15 UTC ( [id://1198325]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @list = (qw(
        a b c d e f
    ...
    
    $by = by_score({ a => -5, b => 4, c => -3, d => 6, e => -1 });
    print join ",", sort( {$by->($a,$b)} @list );
    
  2. or download this
    $by = by_score({ a => -5, b => 4, c => -3, d => 6, e => -1 });
    print join ",", sort( $by, @list );
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-24 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found