Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Sorting Hash By Large Number Values

by JediWizard (Deacon)
on Aug 02, 2005 at 23:36 UTC ( [id://480318]=note: print w/replies, xml ) Need Help??


in reply to Sorting Hash By Large Number Values

you need to use numeric comparison rather than string comparison. Aka. <=> or the "spacship operator". Change cmp to <=>. See perlop

Update In the intrest of being complete: You may have troubles if not all values are numeric. I believe that Regex::Common::Number can help you identify numbers as opposed to strings.

Update 2: I just checked.... numbers should sort lexicographically prior to letters... that should not cause much of an issue. Sorry for the false lead.


They say that time changes things, but you actually have to change them yourself.

—Andy Warhol

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-03-28 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found