Ironic observation about `sort` and `sortperm` speed for "small integers" vs R

Have you tried the sortperm_int_range4 function that I wrote? Curious as to how it performs on your machine.