Adding a generic topological sort for the update pipeline.

Will do.