@@ -346,7 +346,10 @@ func (mc *MetricsCollector) GetMetrics() map[string]interface{} {
346346
347347 // Sort by increasing average response time (faster servers first)
348348 sort .Slice (serverPerfs , func (i , j int ) bool {
349- return serverPerfs [i ].avgTime < serverPerfs [j ].avgTime
349+ if serverPerfs [i ].avgTime != serverPerfs [j ].avgTime {
350+ return serverPerfs [i ].avgTime < serverPerfs [j ].avgTime
351+ }
352+ return serverPerfs [i ].name < serverPerfs [j ].name
350353 })
351354
352355 // Convert to map for JSON output
@@ -373,7 +376,10 @@ func (mc *MetricsCollector) GetMetrics() map[string]interface{} {
373376
374377 // Sort by decreasing count
375378 sort .Slice (domainCounts , func (i , j int ) bool {
376- return domainCounts [i ].count > domainCounts [j ].count
379+ if domainCounts [i ].count != domainCounts [j ].count {
380+ return domainCounts [i ].count > domainCounts [j ].count
381+ }
382+ return domainCounts [i ].domain < domainCounts [j ].domain
377383 })
378384
379385 // Take top 20
@@ -405,7 +411,10 @@ func (mc *MetricsCollector) GetMetrics() map[string]interface{} {
405411
406412 // Sort by decreasing count
407413 sort .Slice (queryTypeCounts , func (i , j int ) bool {
408- return queryTypeCounts [i ].count > queryTypeCounts [j ].count
414+ if queryTypeCounts [i ].count != queryTypeCounts [j ].count {
415+ return queryTypeCounts [i ].count > queryTypeCounts [j ].count
416+ }
417+ return queryTypeCounts [i ].qtype < queryTypeCounts [j ].qtype
409418 })
410419
411420 // Take top 10
0 commit comments