Topological sort.