@@ -20686,13 +20686,6 @@ test(2299.10, data.table(a=1), output="a\
2068620686test(2299.11, data.table(a=list(data.frame(b=1))), output="a\n1: <data.frame[1x1]>")
2068720687test(2299.12, data.table(a=list(data.table(b=1))), output="a\n1: <data.table[1x1]>")
2068820688
20689- # sort_by.data.table
20690- DT1 = data.table(a = c(1, 3, 2, NA, 3) , b = 4:0)
20691- DT2 = data.table(a = c("c", "a", "B")) # data.table uses C-locale and should sort_by if cedta()
20692- test(2300.01, sort_by(DT1, ~ a + b), data.table(a = c(1,2,3,3,NA), b = c(4L,2L,0L,3L,1L)))
20693- test(2300.02, sort_by(DT1, ~ I(a + b)), data.table(a = c(3,2,1,3,NA), b = c(0L,2L,4L,3L,1L)))
20694- test(2300.03, sort_by(DT2, ~ a), data.table(a = c("B", "a", "c")))
20695-
2069620689if (test_bit64) {
2069720690 # Join to integer64 doesn't require integer32 representation, just integer64, #6625
2069820691 i64_val = .Machine$integer.max + 1
@@ -20704,3 +20697,30 @@ if (test_bit64) {
2070420697 test(2300.3, DT1[DT2, on='id'], error="Incompatible join types")
2070520698 test(2300.4, DT2[DT1, on='id'], error="Incompatible join types")
2070620699}
20700+
20701+ # sort_by.data.table
20702+ DT1 = data.table(a = c(1, 3, 2, NA, 3) , b = 4:0)
20703+ DT2 = data.table(a = c("c", "a", "B")) # data.table uses C-locale and should sort_by if cedta()
20704+ DT3 = data.table(a = c(1,2,3), b = list(c("a","b","",NA),c(1,3,2,0), c(T,T,F,NA))) # list column
20705+
20706+ # sort_by.data.table: basics
20707+ test(2301.01, sort_by(DT1, ~ a + b), data.table(a = c(1,2,3,3,NA), b = c(4L,2L,0L,3L,1L)))
20708+ test(2301.02, sort_by(DT1, ~ I(a + b)), data.table(a = c(3,2,1,3,NA), b = c(0L,2L,4L,3L,1L)))
20709+ test(2301.03, sort_by(DT2, ~ a), data.table(a = c("B", "a", "c")))
20710+
20711+ # sort_by.data.table: list columns.
20712+ # NOTE 1: .formula2varlist works well with list columns.
20713+ # NOTE 2: 4 elem in DT of 3 row because forderv takes a list column as a DT.
20714+ test(2301.04, sort_by(DT3, ~b), DT3[order(b)]) # should be consistent.
20715+
20716+ # sort_by.data.table: additional C-locale sorting
20717+ test(2301.10, DT2[, sort_by(.SD, a)], data.table(a = c("B", "a", "c")))
20718+ test(2301.11, DT2[, sort_by(.SD, ~ a)], data.table(a = c("B", "a", "c")))
20719+
20720+ # sort_by.data.table: various working interfaces
20721+ test(2301.20, sort_by(DT1, list(DT1$a, DT1$b)), data.table(a = c(1,2,3,3,NA), b = c(4L,2L,0L,3L,1L)))
20722+ test(2301.21, sort_by(DT1, DT1[, .(a, b)]), data.table(a = c(1,2,3,3,NA), b = c(4L,2L,0L,3L,1L)))
20723+ test(2301.22, DT1[, sort_by(.SD, .(a, b))], data.table(a = c(1,2,3,3,NA), b = c(4L,2L,0L,3L,1L)))
20724+ test(2301.23, DT1[, sort_by(.SD, ~ a + b)], data.table(a = c(1,2,3,3,NA), b = c(4L,2L,0L,3L,1L)))
20725+ test(2301.24, DT1[, sort_by(.SD, ~ .(a, b))], data.table(a = c(1,2,3,3,NA), b = c(4L,2L,0L,3L,1L)))
20726+
0 commit comments