Skip to content

Commit

Permalink
chore(ifdata): Sort interfaces by name if no args are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Oct 11, 2024
1 parent eaf62aa commit 71e3619
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/ifdata/cmd.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package ifdata

import (
"cmp"
"errors"
"fmt"
"html/template"
"io"
"net"
"slices"
"strings"

"github.com/gabe565/moreutils/internal/cmdutil"
Expand Down Expand Up @@ -155,6 +157,10 @@ func run(cmd *cobra.Command, args []string) error {
for _, iface := range v {
ifaces = append(ifaces, &iface)
}

slices.SortStableFunc(ifaces, func(a, b *net.Interface) int {
return cmp.Compare(a.Name, b.Name)
})
}

for _, iface := range ifaces {
Expand Down

0 comments on commit 71e3619

Please sign in to comment.