refactor: replace sort.Strings with slices.Sort (#23457)

The slices package provides type-safe generic replacements for the
old typed sort convenience functions. The codebase already uses
slices.Sort in 43 call sites; this finishes the migration for the
remaining 29.

- sort.Strings(x)          -> slices.Sort(x)
- sort.Float64s(x)         -> slices.Sort(x)
- sort.StringsAreSorted(x) -> slices.IsSorted(x)
This commit is contained in:
Mathias Fredriksson
2026-03-23 23:19:23 +02:00
committed by GitHub
parent 9e4c283370
commit 147df5c971
22 changed files with 45 additions and 47 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ package dynamicparameters
import (
"fmt"
"net/http"
"sort"
"slices"
"github.com/hashicorp/hcl/v2"
@@ -94,7 +94,7 @@ func (e *DiagnosticError) Response() (int, codersdk.Response) {
for name := range e.KeyedDiagnostics {
sortedNames = append(sortedNames, name)
}
sort.Strings(sortedNames)
slices.Sort(sortedNames)
for _, name := range sortedNames {
diag := e.KeyedDiagnostics[name]