title: Selection Sort in Cuda
body: <p>So, I'm trying to implement selection sort in Cuda, but so far I haven't been as successful. </p>
  
  <pre><code>__device__ void selection_sort( int *data, int left, int right ){
  
      for( int i = left ; i &lt;= right ; ++i ){
          int min_val = data[i];
          int min_idx = i;
  
      // Find the smallest value in the range [left, right].
          for( int j = i+1 ; j &lt;= right ; ++j ){
              int val_j = data[j];
              if( val_j &lt; min_val ){
                  min_idx = j;
                  min_val = val_j;
              }
          }
  
          // Swap the values.
          if( i != min_idx ){
              data[min_idx] = data[i];
              data[i] = min_val;
          }
      }
  }
  </code></pre>
  
  <p>My main attempt here is to find the minimum and parallelize the solution. Now, I realize the code looks very C++ 'ish but I'm nowhere qualified as skilled in Cuda. </p>
  
  <p>Is there a way to parallelize the solution? Are there any more additions to be made? </p>