Adding a generic topological sort for the update pipeline.

I'll use a sentinel