Skip to content

Commit

Permalink
update stable resutls
Browse files Browse the repository at this point in the history
  • Loading branch information
konoui committed May 5, 2023
1 parent 5ed6c9f commit 21136e2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/sflag/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,24 @@ func (g *Group) AddDescription(s string) *Group {
}

func (g *Group) lookupByType(typ FlagType) []*Flag {
keys, i := make([]string, len(g.types)), 0
for k := range g.types {
keys[i] = k
i++
}
sort.SliceStable(keys, func(i, j int) bool {
if g.Name == keys[i] {
return true
}
if g.Name == keys[j] {
return false
}
return keys[i] > keys[j]
})

flags := []*Flag{}
for name, ft := range g.types {
for _, name := range keys {
ft := g.types[name]
if ft == typ {
flags = append(flags, g.lookup(name))
}
Expand Down

0 comments on commit 21136e2

Please sign in to comment.