How to generate an ordered list of parent-child elements from multiple lists?
I have this problem: Given a number of arrays (for example in Perl, or any other language): 1. (A,B,C) 2. (B,D,E,F) 3. (C,H,G) 4. (G,H) In each array, the first element is the parent, the rest are its children. In this case, element A has two children B and C, and B has three children D, E, and F, etc. I would like to process this set of arrays, and generate a list which contains the correct order. In this case, A is the root element, so comes B and C, then under B is D, E and F, and under C is G and H, and G also has H as children (which means an element can have multiple parent). This should