From 33d0c4ba3abe052d33f3f061a269c89703394b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Wed, 29 May 2024 16:49:53 +0200 Subject: [PATCH] Stable result order for entries with equal confidence --- licensedb/analysis.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/licensedb/analysis.go b/licensedb/analysis.go index 137eca3..5e5faaa 100644 --- a/licensedb/analysis.go +++ b/licensedb/analysis.go @@ -74,6 +74,11 @@ func process(arg string) ([]Match, error) { for k, v := range ls { matches = append(matches, Match{k, v.Confidence, v.File}) } - sort.Slice(matches, func(i, j int) bool { return matches[i].Confidence > matches[j].Confidence }) + sort.Slice(matches, func(i, j int) bool { + if matches[i].Confidence == matches[j].Confidence { + return matches[i].License < matches[j].License + } + return matches[i].Confidence > matches[j].Confidence + }) return matches, nil }