Interesting. You have an array 'index' that has as many elements as the data array, but it does not contain the index of the first element, and it does contain one invalid index (-1).
I presume that you attempt to sort that data indirectly, by updating the array 'index'. You do have a fundamental problem. The first element that you will always print is at index 0 no matter what the 'index' contains. If you had to "swap" the data[0], then some element of 'index' will have 0, the data[0] will be printed twice, and some data element is never printed.
Found my problem :) while (counter != 0); //if counter = 1 exit must be while (counter != 1);
Tnx keskiverto, yea i know that i need to insert data check after swap in this part
1 2 3 4 5 6 7 8 9 10 11 12
if (v != a) {
tmp = index[a];
index[a] = index[tmp];
index[tmp] = a;
index[pt_a] = tmp;
pt_a = tmp;
a = tmp;
if (data[v]>data[tmp]){ //untested part of code
v=tmp;
}
}