title: CUDA Thrust sort_by_key when the key is a tuple dealt with by zip_iterator's with custom comparison predicate
body: <p>I've looked through a lot of questions here for something similar and there are quite a few, albeit with one minor change. I'm trying to sort values with a zip_iterator as a compound key.</p>
  
  <p>Specifically, I have the following function:</p>
  
  <pre>
  void thrustSort(
      unsigned int * primaryKey,
      float * secondaryKey,
      unsigned int * values,
      unsigned int numberOfPoints)
  {
      thrust::device_ptr dev_ptr_pkey = thrust::device_pointer_cast(primaryKey);
      thrust::device_ptr dev_ptr_skey = thrust::device_pointer_cast(secondaryKey); 
      thrust::device_ptr dev_ptr_values = thrust::device_pointer_cast(values);
  
      thrust::tuple,thrust::device_ptr> keytup_begin =
          thrust::make_tuple,thrust::device_ptr>(dev_ptr_pkey, dev_ptr_skey);
  
      thrust::zip_iterator, thrust::device_ptr > > first =
          thrust::make_zip_iterator, thrust::device_ptr > >(keytup_begin);
  
      thrust::sort_by_key(first, first + numberOfPoints, dev_ptr_values, ZipComparator());    
  }
  </pre>
  
  <p>and this custom predicate:</p>
  
  <pre><code>typedef thrust::device_ptr&lt;unsigned int&gt; tdp_uint ;
  typedef thrust::device_ptr&lt;float&gt; tdp_float ;
  typedef thrust::tuple&lt;tdp_uint, tdp_float&gt; tdp_uif_tuple ;
  
  struct ZipComparator
  {
      __host__ __device__
      inline bool operator() (const tdp_uif_tuple &amp;a, const tdp_uif_tuple &amp;b)
      {
          if(a.head &lt; b.head) return true;
          if(a.head == b.head) return a.tail &lt; b.tail;
          return false;
  
      }
  };
  </code></pre>
  
  <p>The errors I'm getting are:</p>
  
  <pre>
  Error   1   error : no instance of constructor "thrust::device_ptr::device_ptr [with T=unsigned int]" matches the argument list  C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\thrust\detail\tuple.inl 309 1   ---
  Error   2   error : no instance of constructor "thrust::device_ptr::device_ptr [with T=float]" matches the argument list C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\thrust\detail\tuple.inl 401 1   ---
  </pre>
  
  <p>Any ideas what might cause this / how do I write a predicate that indeed works?</p>
  
  <p>Thanks in Advance, 
  Nathan</p>