Skip to content

Commit

Permalink
Modify compare procedure
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 5bb2a0b commit a1ac70d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,17 @@ type derivedFromEntry struct {
}

func lessDerivedFromEntry(x, y *derivedFromEntry) bool {
if x.Direction != y.Direction {
return strings.Compare(x.Direction, y.Direction) < 0
ret := strings.Compare(x.Direction, y.Direction)
if ret == 0 {
ret = strings.Compare(x.Kind, y.Kind)
}
if x.Kind != y.Kind {
return strings.Compare(x.Kind, y.Kind) < 0
if ret == 0 {
ret = strings.Compare(x.Namespace, y.Namespace)
}
if x.Namespace != y.Namespace {
return strings.Compare(x.Namespace, y.Namespace) < 0
if ret == 0 {
ret = strings.Compare(x.Name, y.Name)
}
if x.Name != y.Name {
return strings.Compare(x.Name, y.Name) < 0
}
return false
return ret < 0
}

func parseDerivedFromEntry(input []string, direction string) derivedFromEntry {
Expand Down

0 comments on commit a1ac70d

Please sign in to comment.