Browse Source

Fix incorrect use of sort.Slice

XYenon 2 years ago
parent
commit
a0d8e374fb
2 changed files with 2 additions and 2 deletions
  1. 1 1
      experimental/clashapi/proxies.go
  2. 1 1
      outbound/urltest.go

+ 1 - 1
experimental/clashapi/proxies.go

@@ -133,7 +133,7 @@ func getProxies(server *Server, router adapter.Router) func(w http.ResponseWrite
 			defaultTag = allProxies[0]
 		}
 
-		sort.Slice(allProxies, func(i, j int) bool {
+		sort.SliceStable(allProxies, func(i, j int) bool {
 			return allProxies[i] == defaultTag
 		})
 

+ 1 - 1
outbound/urltest.go

@@ -220,7 +220,7 @@ func (g *URLTestGroup) Fallback(used adapter.Outbound) []adapter.Outbound {
 			outbounds = append(outbounds, detour)
 		}
 	}
-	sort.Slice(outbounds, func(i, j int) bool {
+	sort.SliceStable(outbounds, func(i, j int) bool {
 		oi := outbounds[i]
 		oj := outbounds[j]
 		hi := g.history.LoadURLTestHistory(RealTag(oi))