Here you can find the source of insertionSort(int[] a)
public static void insertionSort(int[] a)
//package com.java2s; //License from project: Apache License public class Main { public static void insertionSort(int[] a) { if (a == null || a.length == 0) return; for (int i = 1; i < a.length; i++) { int unsorted = a[i]; // a[0:i-1] is sorted int j = i; while (j > 0 && a[j - 1] > unsorted) { a[j] = a[j - 1];/* ww w .ja va 2s .c o m*/ j--; } a[j] = unsorted; } } }