You need graph basics and understanding of directed acyclic graphs (DAGs). Topological sort orders vertices so that for every directed edge , vertex comes before in the ordering.
Complete Graphs BFS and Graphs DFS first. Both BFS (Kahn's algorithm using in-degree) and DFS (reverse postorder) can produce valid topological orderings.