package com.hj.sort;
import java.util.Arrays;
public class SelectionSort {
public static void main(String[] args) {
int[] array = {33, 12, 3, 5, 34, 6, 2, 7, 1, 3};
selectionSort(array);
System.out.print(Arrays.toString(array));
}
public static void selectionSort(int[] array) {
int temp, index = 0;
for(int i = 0; i < array.length - 1; i++) {
index = i;
for(int j = i+1 ; j < array.length; j++) {
if(array[j] < array[index]) {
index = j;
}
}
if(index != i) {
temp = array[i];
array[i] = array[index];
array[index] = temp;
}
}
}
}