Código:
public static void insertionSort(int[] lista) { int i, ubicacion, temp; for(i = 1; i < lista.length; i++) { //Starts at second term, goes until the end of the array. if(lista[i] < lista[i - 1]) { //If the two are out of order, we move the element to its rightful place. temp = lista[i]; ubicacion = i; do { //Keep moving down the array until we find exactly where it's supposed to go. lista[ubicacion] = lista[ubicacion-1]; ubicacion--; } while (ubicacion > 0 && lista[ubicacion-1] > temp); lista[ubicacion] = temp; } } }