in reply to Sort Algorithm (recursive?)

A sort based on dependencies like that is called a "topological sort". You can find a Perl-based sort for that in the Graph dist as topological_sort.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.