From 1f49f8f216aebfd71a8e8df7948912af95077a73 Mon Sep 17 00:00:00 2001 From: Jon Johnson Date: Mon, 5 Jun 2023 12:26:05 -0700 Subject: [PATCH] StableTopologicalSort: don't eagerly sort queue Signed-off-by: Jon Johnson --- dag.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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()