Skip to content
Prev 10916 / 398502 Next

Benchmarking R, why sort() is so slow?

"Philippe Grosjean" <phgrosje at ulb.ac.be> writes:
The internal algorithm is a shellsort, which is supposedly of
complexity O(n^1.25) and has decent worst-case behaviour. Other
algorithms like quicksort have typical performance of O(n log n) but
extreme cases of O(n^2).

For large vectors the O(n^.25/log(n)) relative complexity is going to
make a difference, although the observed differences seem larger.

There are very likely better choices of sort algorithm...