1 parent b06bd35 commit 854eabfCopy full SHA for 854eabf
1 file changed
pkg/store/types.go
@@ -17,7 +17,7 @@ package store
17
import (
18
"fmt"
19
"net/netip"
20
- "sort"
+ "slices"
21
"time"
22
23
"github.com/haproxytech/client-native/v6/models"
@@ -105,8 +105,14 @@ func SortedRuntimeEndpoints(endpoints RuntimeEndpoints) []RuntimeEndpoint {
105
for endpoint := range endpoints {
106
sortedEndpoints = append(sortedEndpoints, endpoint)
107
}
108
- sort.SliceStable(sortedEndpoints, func(i, j int) bool {
109
- return runtimeEndpointLess(sortedEndpoints[i], sortedEndpoints[j])
+ slices.SortStableFunc(sortedEndpoints, func(a, b RuntimeEndpoint) int {
+ if runtimeEndpointLess(a, b) {
110
+ return -1
111
+ }
112
+ if runtimeEndpointLess(b, a) {
113
+ return 1
114
115
+ return 0
116
})
117
return sortedEndpoints
118
0 commit comments