Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by waswas-fng (Curate)
on Jan 14, 2003 at 01:00 UTC ( [id://226676]=note: print w/replies, xml ) Need Help??


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

while (<DATA>){ chomp; ($itemone) = split/,/; #split at comma $seen{$itemone}++; } foreach my $element (sort { $a <=> $b} keys %seen){ print "$element\n"; } exit; __DATA__ 1,ABC,X,1.203000e+02 1,ABC,Y,7.830000e+00 2,DEF,X,1.212400e+02 2,DEF,Y,8.810000e+00 3,GHI,X,1.180700e+02 3,GHI,Y,8.550000e+00 5,JKL,X,1.193500e+02 5,JKL,Y,7.270000e+00
you forgot to look at the keys for the seen hash, also look how I used $_ those chomp lines etc were real ugly.

-Waswas

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-18 17:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found