I have a list of event lists. Events always occur in a specific order, but not every event always occurs. Here is an example input:
[[ do, re, fa, ti ], [ do, re, mi ], [ do, la, ti, za ], [ mi, fa ], [ re, so, za ]]
Input values โโdo not have a built-in order. These are actually messages such as "creating symbolic links" and "reindexing the search." They are sorted in a separate list, but there is no way to look only at โfaโ in the first list and โmiโ in the second and determine what happens before the other.
I would like to be able to accept this input and create a sorted list of all events:
[ do, re, mi, fa, so, la, ti, za ]
or better yet, some information about each event, for example count:
[ [do, 3], [re, 3], [mi, 2], [fa, 2], [so, 1], [la, 1], [ti, 1], [za, 2] ]
Is there a name for what I'm doing? Are there any accepted algorithms? I write this in Perl if that matters, but the pseudo code will do.
I know that, given my input example, I probably cannot guarantee the "correct" order. But my real contribution has more point data, and I am sure that with some trick he will be 95% right (this is really all I need). I just don't want to reinvent the wheel if I don't need it.