package sort;
import java.util.Arrays;
public class insert_sort {
public static void main(String[] args) {
int[] arr = new int[]{1, 10, -5, 12, 0};
insert_sort(arr);
System.out.println(Arrays.toString(arr));
}
public static void insert_sort(int[] arr) {
for (int i = 1; i < arr.length; i++) {
int insertIndex = i;
int inserValue = arr[i];
while (insertIndex > 0 && inserValue < arr[insertIndex - 1]) {
arr[insertIndex] = arr[insertIndex - 1];
insertIndex--;
}
arr[insertIndex] = inserValue;
}
}
}