- 
                Notifications
    
You must be signed in to change notification settings  - Fork 195
 
Open
Description
Not a super common pattern:
But there is a huge opportunity for optimization here:
x <- runif(1e5)
microbenchmark::microbenchmark(
  identical(x, sort(x)),
  !is.unsorted(x),
  check = "identical"
)
#> Unit: microseconds
#>                   expr      min       lq       mean   median       uq      max
#>  identical(x, sort(x)) 4010.383 4313.883 4636.98955 4496.855 4761.682 7040.232
#>        !is.unsorted(x)   40.104   41.166   46.29157   42.666   46.807   86.509
#>  neval
#>    100
#>    100
x <- sort(x)
microbenchmark::microbenchmark(
  identical(x, sort(x)),
  !is.unsorted(x),
  check = "identical"
)
#> Unit: nanoseconds
#>                   expr  min     lq    mean median     uq   max neval
#>  identical(x, sort(x)) 3612 3732.0 4094.85 3872.5 4033.0 22994   100
#>        !is.unsorted(x)  662  722.5  803.60  773.0  800.5  3131   100Created on 2025-07-30 with reprex v2.1.1
Should probably not lint if na.last = TRUE or FALSE or decreasing = TRUE in sort().
Metadata
Metadata
Assignees
Labels
No labels