topological sort - interface returns queue sorted in right order