Сначала вы должны найти минимум вместо того, чтобы считать, что первым элементом является минимальный
int[] array = {5, 4, 3, 2, 1};
for ( int i = 0; i < array.length; i++ ) {
//find minimum, starting from index i
int minIndex = i;
int min = array[i];
for ( int j = i + 1; j < array.length; j++ ) {
if ( array[ j ] < min ) {
minIndex = j;
min = array[j];
}
}
// now move the smallest element to the front, and the element at index i to the index of the minimal element
int temp = array[ i ];
array[ i ] = min;
array[ minIndex ] = temp;
}