Added Topological Sort and better naming!

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>