Found while working on #7837; Gemini created this minimal reprex:
DT = data.table(
d1 = c(1, 10, 10, 10),
c2 = c('a', 'b', 'c', NA)
)
DT[order(d1, -c2, na.last=TRUE)]
# d1 c2
# <num> <char>
# 1: 1 a
# 2: 10 <NA>
# 3: 10 c
# 4: 10 b
NA must be at the end; c.f.
# equiv. DT[base::order(d1, -xtfrm(c2), na.last=TRUE)]
DT[base::order(-d1, c2, na.last=TRUE, decreasing=TRUE)]
# d1 c2
# <num> <char>
# 1: 1 a
# 2: 10 c
# 3: 10 b
# 4: 10 <NA>
Note that {base} radix sort is not affected which hinted at this being a regression:
DT[base::order(d1, c2, na.last=TRUE, method='radix', decreasing=c(FALSE, TRUE))]
# d1 c2
# <num> <char>
# 1: 1 a
# 2: 10 c
# 3: 10 b
# 4: 10 <NA>
Gemini helped identify #3124 as the culprit by creating a branch off of 88439d9 (parent of #3124 == e59ba14), applying some minimal changes to get it compiling under r-devel as a first commit, then cherry-picking e59ba14 as a second commit. The example above WAI before e59ba14 is applied.
Found while working on #7837; Gemini created this minimal reprex:
NAmust be at the end; c.f.Note that {base} radix sort is not affected which hinted at this being a regression:
Gemini helped identify #3124 as the culprit by creating a branch off of 88439d9 (parent of #3124 == e59ba14), applying some minimal changes to get it compiling under
r-develas a first commit, then cherry-picking e59ba14 as a second commit. The example above WAI before e59ba14 is applied.