public class Demo {
public static void main(String[] args) {
int[] array = {7, 3, 2, 9, 15, 1, 14};
int temp = 0;
for(int i = 0; i < array.length - 1; i++) {
int min = array[i];
int minIndex = i;
for(int j = i + 1; j < array.length; j++) {
if (min < array[j]) {
min = array[j];
minIndex = j;
}
}
temp = array[i];
array[i] = array[minIndex];
array[minIndex] = temp;
}
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
}
}