chore: sort.Slice → slices.SortFunc

This commit is contained in:
Claude 2026-02-24 16:00:38 +00:00
parent 7ae5fee661
commit 2c2f2784a9
No known key found for this signature in database
GPG key ID: AF404715446AEB41
3 changed files with 13 additions and 10 deletions

View file

@ -3,6 +3,7 @@
package cmd
import (
"cmp"
"context"
"encoding/json"
"errors"
@ -11,7 +12,7 @@ import (
"math"
"os"
"runtime"
"sort"
"slices"
"time"
"forge.lthn.ai/core/cli/pkg/cli"
@ -465,6 +466,6 @@ func loadBenchmarkPrompts() ([]benchPrompt, error) {
prompts = append(prompts, benchPrompt{id: id, prompt: r.Prompt})
}
sort.Slice(prompts, func(i, j int) bool { return prompts[i].id < prompts[j].id })
slices.SortFunc(prompts, func(a, b benchPrompt) int { return cmp.Compare(a.id, b.id) })
return prompts, nil
}

View file

@ -1,6 +1,7 @@
package ml
import (
"cmp"
"encoding/binary"
"encoding/json"
"fmt"
@ -8,7 +9,7 @@ import (
"math"
"os"
"regexp"
"sort"
"slices"
"strconv"
"strings"
)
@ -174,8 +175,8 @@ func ConvertMLXtoGGUFLoRA(safetensorsPath, configPath, outputPath, architecture
}
}
sort.Slice(ggufTensors, func(i, j int) bool {
return ggufTensors[i].name < ggufTensors[j].name
slices.SortFunc(ggufTensors, func(a, b ggufTensor) int {
return cmp.Compare(a.name, b.name)
})
metadata := []ggufMetadata{

View file

@ -1,9 +1,10 @@
package ml
import (
"cmp"
"fmt"
"io"
"sort"
"slices"
)
// trainingRow holds deduplicated training status + loss for a single model.
@ -146,8 +147,8 @@ func dedupeTraining(statusRows, lossRows []map[string]any) []trainingRow {
rows = append(rows, tr)
}
sort.Slice(rows, func(i, j int) bool {
return rows[i].model < rows[j].model
slices.SortFunc(rows, func(a, b trainingRow) int {
return cmp.Compare(a.model, b.model)
})
return rows
@ -172,8 +173,8 @@ func dedupeGeneration(rows []map[string]any) []genRow {
})
}
sort.Slice(result, func(i, j int) bool {
return result[i].worker < result[j].worker
slices.SortFunc(result, func(a, b genRow) int {
return cmp.Compare(a.worker, b.worker)
})
return result