···653653func writeFlags(cmd *Command, s *strings.Builder) error {
654654 tw := style.Tabwriter(s)
655655656656- for name, fl := range cmd.flags.All() {
656656+ for name, fl := range cmd.flags.Sorted() {
657657 var shorthand string
658658 if fl.Short() != publicflag.NoShortHand {
659659 shorthand = "-" + string(fl.Short())
+9-2
internal/flag/set.go
···44 "errors"
55 "fmt"
66 "iter"
77+ "maps"
78 "os"
89 "slices"
910 "strings"
···200201 return nil
201202}
202203203203-// All returns an iterator through the flags in the flagset
204204+// Sorted returns an iterator through the flags in the flagset
204205// in alphabetical order by name.
205205-func (s *Set) All() iter.Seq2[string, Value] {
206206+func (s *Set) Sorted() iter.Seq2[string, Value] {
206207 return func(yield func(string, Value) bool) {
207208 names := make([]string, 0, len(s.flags))
208209 for name := range s.flags {
···217218 }
218219 }
219220 }
221221+}
222222+223223+// All returns an iterator through the flags in the flagset
224224+// in alphabetical order by name.
225225+func (s *Set) All() iter.Seq2[string, Value] {
226226+ return maps.All(s.flags)
220227}
221228222229// applyEnvVars looks up each configured environment variable and applies its value