title: CUDA Thrust sort or CUB::DeviceRadixSort
body: <p>I have a pool of particles represented by an array of float4 where the w component is the particle's current lifetime in the range [0, 1].</p>
  
  <p>I need to sort this array based on the lifetime of the particles in descending order so that I can keep an accurate counter for how many particles are currently "active" (lifetime greater than 0). I need this counter because it will allow me to index into the correct spot in the array when I need to activate more particles (which happens randomly).</p>
  
  <p>My array of particles is stored in device memory and it seems like I should be able to sort the array without having to transfer the array to host memory.</p>
  
  <p>I haven't had much luck in finding examples online that show how I could do this with either Thrust or CUB. In addition, I am hesitant to use Thrust because I don't know how to prevent it from degrading into merge-sort (which is far slower than radix sort) since I need to sort based on the w component. As for CUB, I simply haven't found any resources at all as to how I could do this.</p>
  
  <p>I would also prefer to keep the lifetime stored within the w component since this makes my life significantly easier in other parts of my code.</p>
  
  <p>Is there a simple way to do this? Thanks for any help.</p>