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

Re: Sorting an hash array

by Laurent_R (Canon)
on Jul 27, 2014 at 10:57 UTC ( [id://1095221]=note: print w/replies, xml ) Need Help??


in reply to Sorting an hash array

Just for the sake of clarifying the origin of the incomprehension, the OP finally stated on a cross post on Perl Gurus (http://perlguru.com/gforum.cgi?post=79335;sb=post_latest_reply;so=ASC;forum_view=forum_view_collapsed;;page=unread#unread) that he actually wanted to sort the hash alphabetically by the keys, not by the values, so that this would be the right correction for the sorting statement:
my @keys = sort keys %functions;
Actually, the whole code could be reduced to something as simple as this:
my $info = "out.txt"; open my $out,">", $info or die "could not open $info $!"; print $out "Key: $_ and Value: $functions{$_}\n" for sort keys %functi +ons; close $out;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-24 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found