Here you can find the source of insertionSortInPlaceSwap(int[] xs)
public static void insertionSortInPlaceSwap(int[] xs)
//package com.java2s; //License from project: Creative Commons License public class Main { public static void insertionSortInPlaceSwap(int[] xs) { for (int i = 1; i < xs.length; i++) { int j = i; while (j > 0 && xs[j - 1] > xs[j]) { swap(xs, j, j - 1);//from w w w . ja v a2 s . co m j = j - 1; } } } private static void swap(int[] xs, int a, int b) { int temp = xs[a]; xs[a] = xs[b]; xs[b] = temp; } }