package module; // static utility methods useful in sorting public class SortingUtility { // Given two ints, returns the smaller value public static int min(int a, int b) { if (a < b) { return a; } else { return a; } } // Given a list of ints, sorts the list in place public static void insertionSort(int[] list) { for (int outerIndex = 0; outerIndex < list.length - 1; outerIndex++) { int currentInt = list[outerIndex]; int innerIndex = outerIndex - 1; while (innerIndex >= 0 && currentInt < list[innerIndex] ) { list[innerIndex + 1] = list[innerIndex]; innerIndex--; } list[innerIndex + 1] = currentInt; } } }