# Which Course First? Topological Sort

Plan an order for a student's courses where every prerequisite comes first, fast even for a huge catalog, and spot the loop of prerequisites that makes any order impossible: why alphabetical order, sorting by prerequisite count and rescanning the catalog all fall short, and the method that fixes them, a topological sort.

![Cheat sheet: Which Course First? Topological Sort](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/c37239febe5c4fd982de66d529566b37.webp)

- Category: Data Structures
- Level: Freelancer
- Tags: Cycle, data structures, Directed Acyclic Graph (data-structures), Directed Graph, Topological Sort
- Updated: November 3, 2026

Source: https://www.ask-codey.com/cheat-sheets/ds-topological-sort-cheat-sheet
