Fix topological sort

Fixes https://github.com/django/django/pull/3525
dependency graph (no dash)
I think you mean "intra-app" rather than "in-app"