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

Re: Sorting a hash. What am I doing wrong?

by Enlil (Parson)
on Jan 14, 2003 at 00:28 UTC ( [id://226667]=note: print w/replies, xml ) Need Help??


in reply to Sorting a hash. What am I doing wrong?

what you are doing with this:
@uniq = sort {$seen{$a} <=> $seen{$b} } keys %seen;
is sorting the values stored in $seen{$a} against $seen{$b}, what you want is to sort the hash keys (not the hash values) then you want to just do something like the following:
@uniq = sort {$a <=> $b } keys %seen;

-enlil

Replies are listed 'Best First'.
Re: Re: Sorting a hash. What am I doing wrong?
by mndoci (Scribe) on Jan 14, 2003 at 00:42 UTC

    Duh

    And you are quite correct, of course.

    Thanks

    mndoci

    "What you do in this world is a matter of no consequence. The question is, what can you make people believe that you have done?"-Sherlock Holmes in 'A study in scarlet'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-04-23 13:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found