require(data.table)
w <- c(NaN, Inf, -Inf)
x <- c(-Inf, 0, Inf)
y <- c(0, NaN)
z <- c(NaN, 0)
data.table:::forderv(w, retGrp=TRUE) # correct
# [1] 1 3 2
# attr(,"starts")
# [1] 1 2 3
# attr(,"maxgrpn")
# [1] 1
data.table:::forderv(x, retGrp=TRUE) # incorrect
# integer(0)
# attr(,"starts")
# [1] 1
# attr(,"maxgrpn")
# [1] 3
data.table:::forderv(y, retGrp=TRUE) # incorrect
# integer(0)
# attr(,"starts")
# [1] 1
# attr(,"maxgrpn")
# [1] 2
data.table:::forderv(z, retGrp=TRUE) # incorrect
# integer(0)
# attr(,"starts")
# [1] 1
# attr(,"maxgrpn")
# [1] 2