Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Hash sort again!!

by coolmichael (Deacon)
on Apr 26, 2001 at 12:52 UTC ( #75735=note: print w/replies, xml ) Need Help??


in reply to Hash sort again!!

In addition to all the other suggestions, you could also try changing
sort {$a<=>$b} (keys (%sentence_count));
to
my @sortedkeys = sort keys %sentence_count;

sort is smart enough to figure out how to do the comparison for you. Once the array returned by keys is sorted, you need to assign it to another array. Sort won't change the order of the keys directly, but will return a new sorted array.

michael
the blue haired monk

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://75735]
help
Chatterbox?
[LanX]: met a guy from Aberdeen durin holidays, liked Scotsish accent a lot ... very phonetic
[LanX]: ... understood everything after mentally write down what he said.
[choroba]: Trainspotting?
[choroba]: Ouch, trailing commas in JSON :-(
[LanX]: ... though there seems to exist a taxation for the letter 't' in Northern Bri''ain ;-)
[LanX]: never seen trainspotting in OV ... :(
[karlgoethebier]: LanX
[LanX]: They should teach Scottish in continental schools after Brexit !!!

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2018-02-19 10:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (261 votes). Check out past polls.

    Notices?