From 0e43978a79c27f8bc4fd56eb939285c27ff2dce1 Mon Sep 17 00:00:00 2001 From: Daichi Sakaue Date: Wed, 16 Oct 2024 15:29:03 +0900 Subject: [PATCH] Fix compare result Signed-off-by: Daichi Sakaue --- cmd/list.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/list.go b/cmd/list.go index b9b02ba..6ce423c 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -43,8 +43,8 @@ type derivedFromEntry struct { } func lessDerivedFromEntry(x, y *derivedFromEntry) bool { - if strings.Compare(x.Direction, y.Direction) < 0 { - return true + if x.Direction != y.Direction { + return strings.Compare(x.Direction, y.Direction) < 0 } if x.Kind != y.Kind { return strings.Compare(x.Kind, y.Kind) < 0 @@ -114,7 +114,7 @@ func runList(ctx context.Context, w io.Writer, name string) error { } policyList := maps.Keys(policySet) - sort.Slice(policyList, func(i, j int) bool { return compareDerivedFromEntry(&policyList[i], &policyList[j]) }) + sort.Slice(policyList, func(i, j int) bool { return lessDerivedFromEntry(&policyList[i], &policyList[j]) }) switch rootOptions.output { case OutputJson: