Sorting array problem

Hello,

I’m trying to sort an array. I’ve made this kernel.

global void sort_table(fileChar *chars, fileChar *charsOut){
int index = (blockIdx.x * blockDim.x) + threadIdx.x;
int i, rank = 0;

shared fileChar table[256];
table[index] = chars[index];

for (i = 0; i < blockDim.x * blockDim.y; ++i) {
if (index == i)
continue;
if(table[i].prob < table[index].prob) rank++;
else if(table[i].prob == table[index].prob && i < index) rank++;
}
charsOut[rank] = table[index];
__syncthreads();
}

Can anyone tell what is going wrong on this?

Thanks

Can anyone help me? If you need more details please ask…

blockDim.x * blockDim.y What is this?
Block consist of blockDim.x * blockDim.y threads, each performs this kernel.
I see you use only one block to sort an array. how do you launch a kernel?