---
slug: /gold/topological-sort
title: "Topological Sort"
author: Benjamin Qi
order: 4
Assumes familiarity with "Silver - Depth First Search."
A [topological sort](https://en.wikipedia.org/wiki/Topological_sorting) of a directed graph is a linear ordering of its vertices such that for every directed edge $u\to v$ from vertex $u$ to vertex $v$, $u$ comes before $v$ in the ordering.
<!-- END DESCRIPTION -->
## Example Problems
- [CSES Course Schedule](https://cses.fi/problemset/task/1679)
- [CSES Longest Flight Route](https://cses.fi/problemset/task/1680)
- [CSES Game Routes](https://cses.fi/problemset/task/1681)
## Tutorial
- CPH 16.1, 16.2
- [cp-algorithms](https://cp-algorithms.com/graph/topological-sort.html)
-
## Problems
- USACO Gold
- [Timeline](http://www.usaco.org/index.php?page=viewproblem2&cpid=1017)
- [Milking Order](http://www.usaco.org/index.php?page=viewproblem2&cpid=838)
- Other
- [Minimal Labels](http://codeforces.com/contest/825/problem/E) [](53)
- [Quantum](https://open.kattis.com/contests/acpc17open/problems/quantumsuperposition) [](84)