Firstly, my selectionsort works by finding the biggest and smallest value in an array in putting them at their respective positions. As is, it works about half the time, the other half a random value or two will be out of place and I can't seem to pinpoint why.

private void selectionSort(int x[]) { int big = 0; int little = 0; for(int i = 0; i < x.length/2; i++) { big = x[i]; little = x[i]; int littleIndex = i, bigIndex = i; for(int j = i; j < x.length-i; j++) { if(x[j] < little) { little = x[j]; littleIndex = j; } else if(x[j] > big) { big = x[j]; bigIndex = j; } } int temp = x[i]; x[i] = little; x[littleIndex] = temp; temp = x[x.length-1-i]; x[x.length-1-i] = big; x[bigIndex] = temp; } }

Also, I haven't really tried/thought about how it would play with an array with an odd number of ints. The general buzz in my head says that it should all work out just fine, but I'm not sure. Anyone know if I'll have to do something special with the middle-est value? IF that problem should arise, I plan to just take that value and use insertion sort on it.

Thanks in advance for any help in making this sort work out.