Java examples for Data Structure:Sort
insertion Sort int array
//package com.java2s; public class Main { public static void insertionSort(int[] a) { insertionSort(a, 0, a.length);/* www. ja va 2 s .c om*/ } public static void insertionSort(int[] a, int start, int end) { int n = a.length; for (int i = start + 1; i < end; i++) { int iv = a[i]; int j = i - 1; for (; j >= start && a[j] > iv; j--) { a[j + 1] = a[j]; } a[j + 1] = iv; } } }