Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^3: Sort hash with values

by AnomalousMonk (Canon)
on Jun 24, 2013 at 19:44 UTC ( #1040484=note: print w/ replies, xml ) Need Help??

in reply to Re^2: Sort hash with values
in thread Sort hash with values

The only change i have done is reversing the hash.

A naive hash reversal works just fine if the hash values are unique to begin with. If they're not, somebody's gonna get (silently) clobbered. Maybe add a pre/post reversal size check:

>perl -wMstrict -le "my %hash = qw(a aye b bee c see eh aye); ;; my $pre_k = keys %hash; %hash = reverse %hash; $pre_k == keys %hash or die 'somebody got clobbered'; " somebody got clobbered at -e line 1.

Comment on Re^3: Sort hash with values
Download Code
Replies are listed 'Best First'.
Re^4: Sort hash with values
by sammy_01 (Initiate) on Jun 25, 2013 at 10:53 UTC
    Oh Yes, i do agree with you.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-11-28 13:09 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (741 votes), past polls