package capitulo04.bloque03;

import static capitulo04.utils.Utils.crearArrayNumsAleatorios;
import static capitulo04.utils.Utils.mostrarArrayNums;

public class Ejercicio02 {
    public static void main(String[] args) {
        int[] nums150 = crearArrayNumsAleatorios(150, 0, 1000);
        mostrarArrayNums(nums150);
        System.out.println();
        mostrarArrayNums(ordenarInsersionDirecta(nums150));
    }
    public static int[] ordenarInsersionDirecta(int[] array) {
        for (int i = 1; i < array.length; i++) {
            int tempVar = i;
            for (int j = tempVar - 1; j < tempVar && j >= 0; j--) {
                if (array[tempVar] < array[j]) {
                    int tempNum = array[tempVar];
                    array[tempVar] = array[j];
                    array[j] = tempNum;
                }
                tempVar--;
            }
        }
        return array;
    }
}
