Adding a generic topological sort for the update pipeline.

The reason this was IReadOnlyList is to avoid possible multiple enumerations of the IEnumerable, which can cause subtle bugs as well as having perf implemetations. Can we consider if we really want to use this with IEnumerables, and/or whether or not the IEnumerables elsewhere might be better replaced with something stronger?