SPUG: Sorting hash question
Peter Darley
pdarley at kinesis-cem.com
Tue Apr 30 18:27:45 CDT 2002
Marc,
I took a look at this. Since I have hashes of hashes of hashes I think
this would get to be pretty unwieldy pretty quickly. Thanks for the
suggestion tho!
Thanks,
Peter Darley
-----Original Message-----
From: owner-spug-list at pm.org [mailto:owner-spug-list at pm.org]On Behalf Of
Marc M. Adkins
Sent: Tuesday, April 30, 2002 3:44 PM
To: SPUG
Subject: SPUG: Sorting hash question
You might try the Tie-SortHash module on CPAN:
http://search.cpan.org/doc/CTWETEN/Tie-SortHash-1.01/SortHash.pm
It is designed to return keys in sorted order. Don't know how much more
efficient it will be than your default solution.
mma
> I'm getting at the Children of Item using:
> for $SubItem (values %{$$Item{Children}})
>
> which gives me an unsorted list of items. I would like to
> have it sorted
> in the order of the keys of the %{$Item{Children}}. I found lots
> of info on
> how to step through the keys of a hash sorted by value, but not
> anything on
> stepping through the values of a has sorted by key. Is this
> easily doable,
> or should I do something like:
>
> for $SubItem (sort {$a<=>$b} keys %{$$Item{Children}})
> {
> $SubItem = $$Item{Children}{$SubItem};
> ...
> }
>
> I would be greatfull for any suggestion! :)
> Thanks,
> Peter Darley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list