[sf-perl] Happy fun sorting problem
David Fetter
david at fetter.org
Fri Jun 10 09:51:03 PDT 2005
On Fri, Jun 10, 2005 at 09:36:51AM -0700, Josh Berkus wrote:
> Folks,
>
> I can think of a few ways to solve this issue, but none that are elegant. I'm
> looking for elegant.
>
> I have a 3-level heirarchy:
>
> Category
> Sub Category
> Item = Value
>
> I want to print output that formats like:
>
> Category-1
> Sub Category-H
> Item_a = Value
> Item_f = Value
> Sub Category-S
> Item_d = Value
> Category-2
> Sub Category-B
> Item_k = Value
> ...etc...
>
> The idea being to group by sorted category, then by sorted subcategory, then
> sort the items on their keys within that. The Items happen to be unique, but
> I'm not sure that makes a difference to the problem. To further complicate
> things, the "Category" level is being sorted according to an external
> ordering list and not alphabetically.
>
> Inside a database, I would just query and sort. But this is
> completely in perl. What's the standard way of dealing with this?
> Hashes of hashes?
perldoc perlfaq4 goes into this in detail :)
Cheers,
D
--
David Fetter david at fetter.org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778
Remember to vote!
More information about the SanFrancisco-pm
mailing list