import java.util.Arrays;

public class InsertionSort {

	
	public void insertionSort( int[] valores ) {
		for (int i = 1; i < valores.length; i++) {
			int temp = valores[i];
			int j;
			
			for (j = i - 1; j >= 0; j--){
				if (valores[j] < temp) {
					break;
				}
				valores[j+1] = valores[j];
			}
			valores[j+1] = temp;
		}
	}

	public static void main(String[] args) {
		int[] valores = {1, 2, 4, 5, 6, 8};
		InsertionSort sort = new InsertionSort();
		sort.insertionSort(valores);
		
		System.out.println(Arrays.toString(valores));
	}

}
