order layers by MRO before doing topological sort