From 80a4ef3c6cdea2bbcf73ea063136b0ab1e84d904 Mon Sep 17 00:00:00 2001 From: elza <44083691+elza2@users.noreply.github.com> Date: Tue, 12 Sep 2023 17:02:05 +0800 Subject: [PATCH] EL-002(feat): sorted cycle. (#7) Co-authored-by: yuanyou --- core/detector.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/detector.go b/core/detector.go index 698c5b4..69747a4 100644 --- a/core/detector.go +++ b/core/detector.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "regexp" + "sort" "strings" "github.com/fatih/color" @@ -358,6 +359,9 @@ func (c *CyclicDetector) QueryCycleNodes( } func PrintCycle(cycle []string) { + sort.Slice(cycle, func(i, j int) bool { + return cycle[i] > cycle[j] + }) downMark, vertical, startPre, endPre := "↓", "┆", "┌---→", "└--- " output := make([]string, 0) length := -1