Topologically sort directed acyclic graphs (such as dependency lists) in node.js