import java.util.Arrays;


public class SelectionSort {
	
	public void selectionSort(int[] valores){
		int menorValor;
		
		for ( int indice=0; indice<valores.length-1; indice++ ){
			menorValor = indice;
			
			for (int j=indice+1; j<valores.length; j++){
				if (valores[menorValor]>valores[j]) {
					menorValor = j;
				}
			}
			
			if (menorValor!=indice){
				int aux = valores[indice];
				valores[indice] = valores[menorValor];
				valores[menorValor] = aux;
			}
			
		}
	}
		
	public static void main(String[] args) {
		int[] valores = {4, 6, 8, 1, 5, 2};
		SelectionSort sort = new SelectionSort();
		sort.selectionSort(valores);
		
		System.out.println(Arrays.toString(valores));
	}
}
