[R-pkg-devel] R_orderVector1 - algo: radix, shell, or another?
? Sun, 24 Sep 2023 10:38:41 +0200 Jan Gorecki <j.gorecki at wit.edu.pl> ?????:
could anyone describe which one R_orderVector1 uses,
The body of the sorting algorithm is defined in the sort2_with_index macro. This is shell sort. (I don't actually recognise sorting algorithms on sight, but the "sincs" array gave it away: <https://discourse.julialang.org/t/ironic-observation-about-sort-and-sortperm-speed-for-small-integers-vs-r/8715/3>.)
and if there is easy API to use different ones from C?
No easy ones, I think. You could construct a call to order(..., method = 'radix') from R or bundle a sort implementation of your own. These are all undocumented implementation details. They could change in a new version of R (although quite a lot of it hasn't changed in 11-22 years). Why are you looking for specific sorting algorithms? Could there be a better way to solve your problem?
Best regards, Ivan