Yes, thrust::sortit can be combined with an execution policy thrust::seqto sequentially sort numbers in a single CUDA thread (or sequentially within a single CPU thread):
#include <thrust/sort.h>
#include <thrust/execution_policy.h>
__global__
void mykernel(float* array, int arrayLength)
{
int threadID = blockIdx.x * blockDim.x + threadIdx.x;
thrust::sort(thrust::seq, array, array + arrayLength);
}
Note that your example causes a data race because each CUDA thread tries to sort the same data in parallel. A proper non-racing program would split arrayaccording to the flow index.
thrust::seq, , Thrust v1.8 .