Skip to content

Commit

Permalink
Fix compare result
Browse files Browse the repository at this point in the history
Signed-off-by: Daichi Sakaue <[email protected]>
  • Loading branch information
yokaze committed Oct 16, 2024
1 parent eb5ba6d commit 0e43978
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0e43978

Please sign in to comment.