Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Sorting data structure

by davido (Cardinal)
on Oct 14, 2005 at 03:02 UTC ( [id://500112]=note: print w/replies, xml ) Need Help??


in reply to Sorting data structure

Something like this (assuming 'count' contains a numeric value):

my( @sorted ) = sort { $users{$a}->{count} <=> $users{$b}->{count} } keys %users; print "$_ => $users{$_}->{count}\n" foreach @sorted;

Dave

Replies are listed 'Best First'.
Re^2: Sorting data structure
by leriksen (Curate) on Oct 14, 2005 at 04:09 UTC
    And if it isn't numeric, replace the '<=>' (spaceship operator) with 'cmp' .

    ...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-03-19 04:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found