Use a topological sort to order traits by requirements.

The original sort using a comparator does not work as required here. For
example, both (Rack <=> Jar) and (Jar <=> War) are 0 (since neither depends on
the other). By the rules of sort, this should imply that (Rack <=> War) is also
zero, since sort requires the comparator be transitive. However, this is not
true, as Rack depends on War.

This patch fixes this problem by using tsort, which is the appropriate mechanism
for sorting DAGs like trait requirements.