On Sun, 22 Feb 2004, Anthony Vanelverdinghe wrote:

> Hi
> 
> Could anyone explain why the output of the hash isn't:           1   a
>                                                                              
>            2   b
>                                                                              
>            3   c
> %c = @count;
> foreach $abc (keys %c){
>    print $abc.'   '.$c{$abc}."\n";
> }

Hash keys are not ordered internally. The output from "keys %c" is in
"internal order", which is not what we would call "ordered" at all. If you
want it in "proper" order, you must sort them.

foreach $abc (sort keys %c) {
        print $abc.   .$c{$abc}."\n";
}

--
Maranatha!
John McKown


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to