Here is a reprex:
lintr::lint(linters = list(lintr::sort_linter()), text = "
x = c(1, 2, 3, 4)
y = c(NA, 10, 20, NA)
x[order(y, x)]
")
#> <text>:4:3: warning: [sort_linter] sort(y, na.last = TRUE) is better than y[order(y, x)].
#> x[order(y, x)]
#> ^~~~~~~~~~~
Obviously sort(y, na.last = TRUE) does not generate what x[order(y, x)] does.
x = c(1, 2, 3, 4)
y = c(NA, 10, 20, NA)
x[order(y, x)]
#> [1] 2 3 1 4
sort(y, na.last = TRUE)
#> [1] 10 20 NA NA
Here is a reprex:
Obviously
sort(y, na.last = TRUE)does not generate whatx[order(y, x)]does.