perl
Sort::Tree implements a mechanism for sorting a list of objects into a
tree structure and flattening it back into a list. Among other things,
this is useful for displaying database queries in hierarchical views,
such as nested categories, parent-child relationships, threaded
discussions, and so forth.