Working topo sort