Topological sort. Eh... Currently not ACed...