MAINT: use reverse=True for some topological_sort calls