You can do a schwartzian transform ....

        @hosts = (blah..blah..blah);

        my @sorted =
                map { $_->[0] }
                sort { $a->[1] cmp $b->[1] }
                map { [$_,$_->{name} }
                @hosts;


        foreach my $h (@sorted) {
                foreach my $k (keys %$h) {
                        print "key $k has the value $h->{$k}\n";
                }
                print "New host\n";
        }

wah lah! ... i am using the schwartzian transform 'cos i kinda just got round
to reading about it in effective perl and i think it is kewl ... anyone know a
better way of implementing this solution feel free to suggest as well ...

On Mon, Sep 24, 2001 at 09:39:07AM +0100, Batchelor, Jonathan shaped the electrons to 
read:
> I have a data structure similar to the following:
> 
> @hosts = ( list of hashes like below ... );
> %hosts = ( name => "hostname",
>            ipaddr => "www.xxx.yyy.zzz",
>            location => "location"
>          );
> 
> How can produce a sorted list of the hashes based on the hostname and then
> access each hash to print the details.
> 
> Or is there a better way of organising my data?
> 
> Cheers,
> Jonathan Batchelor
> 
> 
> 
> ------------------------------------------------------------------------------
> This message is intended only for the personal and confidential use of the 
>designated recipient(s) named above.  If you are not the intended recipient of this 
>message you are hereby notified that any review, dissemination, distribution or 
>copying of this message is strictly prohibited.  This communication is for 
>information purposes only and should not be regarded as an offer to sell or as a 
>solicitation of an offer to buy any financial product, an official confirmation of 
>any transaction, or as an official statement of Lehman Brothers.  Email transmission 
>cannot be guaranteed to be secure or error-free.  Therefore, we do not represent that 
>this information is complete or accurate and it should not be relied upon as such.  
>All information is subject to change without notice.
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to