Create TopSort helpers

This is what I think it's going to look like, but I haven't really started to implement it yet, so the design might
change significantly in future commits.