diff --git a/dag.go b/dag.go index b83f805c..8693f567 100644 --- a/dag.go +++ b/dag.go @@ -114,12 +114,12 @@ func StableTopologicalSort[K comparable, T any](g Graph[K, T], less func(K, K) b if len(predecessors) == 0 { queue = append(queue, vertex) - - sort.Slice(queue, func(i, j int) bool { - return less(queue[i], queue[j]) - }) } } + + sort.Slice(queue, func(i, j int) bool { + return less(queue[i], queue[j]) + }) } gOrder, err := g.Order()