Topological sort of the DAG.