Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Sorting on a split hash value

by flounder99 (Friar)
on Jan 15, 2004 at 13:40 UTC ( [id://321548]=note: print w/replies, xml ) Need Help??


in reply to Sorting on a split hash value

You can do something similar to the Schwartian transform
use strict; use warnings; my %games = ( abraham => "12::Soccer::1/1/2003", bertha => "10::Pool::3/3/2000", charly => "8::Basketball::5/5/2002", ); for (sort {$b->[0] <=> $a->[0]} map [split(/::/, $games{$_}), $_], keys %games ) { print $_->[-1], " score = ", $_->[0], "\tgame = ", $_->[1], "\ +n"; }
outputs
abraham score = 12 game = Soccer bertha score = 10 game = Pool charly score = 8 game = Basketball

--

flounder

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found