typo
[FIXED JENKINS-17247]

Reimplemented a proper topological sort and generates a total order
comparison function.