Fix topological sort

Fixes https://github.com/django/django/pull/3525
I'd rather not drop the concrete creation of two instances here to false positive test cases. The operations when running migrate will create new fields and as such are different instances. (This applies for all the test cases).