Support sorting of multiple libraries.

This amends the topogrophical sort function to accept multiple starting nodes.