Skip to content

Commit

Permalink
Fixed double sorting due to #8
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorunic committed Apr 8, 2022
1 parent 0957965 commit 8cbbe11
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
4 changes: 0 additions & 4 deletions hid/hid.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ import (
"bufio"
"fmt"
"math"
"sort"
"strconv"
"strings"
)
import "github.com/fvbommel/sortorder"

const (
SensorSeparator = ":"
Expand Down Expand Up @@ -66,8 +64,6 @@ func getGeneric(unit string, cStr *C.char) map[string]interface{} {
}
}

sort.Slice(stats, func(i, j int) bool { return sortorder.NaturalLess(stats[i].Name, stats[j].Name) })

generic := make(map[string]interface{})

for _, v := range stats {
Expand Down
5 changes: 3 additions & 2 deletions output/tableoutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"sort"

"github.com/fvbommel/sortorder"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/jedib0t/go-pretty/v6/text"
)
Expand All @@ -46,7 +47,7 @@ func (to TableOutput) All() {
for k := range all {
keys = append(keys, k)
}
sort.Strings(keys)
sort.Sort(sortorder.Natural(keys))

for _, key := range keys {
value := all[key]
Expand Down Expand Up @@ -94,7 +95,7 @@ func (to TableOutput) print(name string, smcdata map[string]interface{}) {
for k := range smcdata {
keys = append(keys, k)
}
sort.Strings(keys)
sort.Sort(sortorder.Natural(keys))

for _, k := range keys {
v := smcdata[k]
Expand Down
4 changes: 0 additions & 4 deletions smc/smc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import (
"fmt"
"math"
"os"
"sort"
"strconv"
"strings"

"github.com/fvbommel/sortorder"
"github.com/panotza/gosmc"
)

Expand Down Expand Up @@ -148,8 +146,6 @@ func getGeneric(desc, unit string, smcSlice []SensorStat) map[string]interface{}
}
defer gosmc.SMCClose(conn)

sort.Slice(smcSlice, func(i, j int) bool { return sortorder.NaturalLess(smcSlice[i].Desc, smcSlice[j].Desc) })

generic := make(map[string]interface{})

for _, v := range smcSlice {
Expand Down

0 comments on commit 8cbbe11

Please sign in to comment.