Sort NaN as the lowest value.
Currently it ends up in a random position.
This commit is contained in:
parent
e681a57d73
commit
6c1689f0c6
|
@ -169,6 +169,9 @@ func (s vectorByValueHeap) Len() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s vectorByValueHeap) Less(i, j int) bool {
|
func (s vectorByValueHeap) Less(i, j int) bool {
|
||||||
|
if math.IsNaN(float64(s[i].Value)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
return s[i].Value < s[j].Value
|
return s[i].Value < s[j].Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,19 @@ func TestExpressions(t *testing.T) {
|
||||||
`http_requests{group="canary", instance="1", job="app-server"} => 800 @[%v]`,
|
`http_requests{group="canary", instance="1", job="app-server"} => 800 @[%v]`,
|
||||||
},
|
},
|
||||||
checkOrder: true,
|
checkOrder: true,
|
||||||
|
}, {
|
||||||
|
expr: `sort(0 / round(http_requests, 400) + http_requests)`,
|
||||||
|
output: []string{
|
||||||
|
`{group="production", instance="0", job="api-server"} => NaN @[%v]`,
|
||||||
|
`{group="production", instance="1", job="api-server"} => 200 @[%v]`,
|
||||||
|
`{group="canary", instance="0", job="api-server"} => 300 @[%v]`,
|
||||||
|
`{group="canary", instance="1", job="api-server"} => 400 @[%v]`,
|
||||||
|
`{group="production", instance="0", job="app-server"} => 500 @[%v]`,
|
||||||
|
`{group="production", instance="1", job="app-server"} => 600 @[%v]`,
|
||||||
|
`{group="canary", instance="0", job="app-server"} => 700 @[%v]`,
|
||||||
|
`{group="canary", instance="1", job="app-server"} => 800 @[%v]`,
|
||||||
|
},
|
||||||
|
checkOrder: true,
|
||||||
}, {
|
}, {
|
||||||
expr: `sort_desc(http_requests)`,
|
expr: `sort_desc(http_requests)`,
|
||||||
output: []string{
|
output: []string{
|
||||||
|
|
Loading…
Reference in New Issue