[sf-perl] Happy fun sorting problem
Josh Berkus
josh at agliodbs.com
Fri Jun 10 09:36:51 PDT 2005
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?
--
Josh Berkus
Aglio Database Solutions
San Francisco
More information about the SanFrancisco-pm
mailing list