@s.v,
https://ide.codingblocks.com/s/286289 corrected code.
Error:
Swap the elements outside the inner loop.
This:
for (int counter = 0; counter < array.length - 1; counter++) {
int min = counter;
for (int j = counter + 1; j <= array.length - 1; j++) {
if (array[j] < array[min]) {
min = j;
}
}
int temp = array[min];
array[min] = array[counter];
array[counter] = temp;
}
Instead of:
for (int counter = 0; counter < array.length - 1; counter++) {
int min = counter;
for (int j = counter + 1; j <= array.length-1; j++) {
if (array[j] < array[min]) {
min = j;
}
int temp = array[min];
array[min] = array[counter];
array[counter] = temp;
}
}