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