Problem with simple selection sort

Hi . I just got interested in OpenCL and GPGPU and wanted to try a simple selection sort code
I have an array with the length of 9 integers . the numbers are : 3,14,4,6,-45,4,23,5,1

I’m using this as my OpenCL code ( Inside Visual studio using ) :

__kernel void ParallelSelection(__global int * in1)
                  int i = get_global_id(0); // current thread
                  int n = get_global_size(0); // input size
                    int temp;
                  for (int j = i + 1; j < n; j++)
                                        if (in1[j] < in1[i])
                                            temp = in1[j];
                                            in1[j] = in1[i];
                                            in1[i] = temp;

And also I’m using ReadFromDeviceTo method from OpenCLTemplate assembly to get the array values back from GPU memory

the odd thing is sorted output is not sorted and in fact is crazy : 3,-45,1,4,6,4,5,4,5

I’m a total beginner and I don’t have good info about OpenCL an all .
What I’m doing wrong ?! please help