for(y; y <= index; y++) { for(x; x <= index-1; x++) { if (a[x] > a[x+1]) { int t = a[x]; a[x] = a[x+1]; a[x+1] = t; } } }