Here you can find the source of sort(int[] array)
public static void sort(int[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static void sort(int[] array) { privateSort(array, 0, array.length - 1); }/*ww w. j ava 2 s.c om*/ public static void sort(int[] array, int leftBorder, int rightBorder) { boundsTest(array.length, leftBorder, rightBorder); privateSort(array, leftBorder, rightBorder); } private static void privateSort(int[] array, int leftBorder, int rightBorder) { if (leftBorder >= rightBorder) { return; } int start = leftBorder; int end = rightBorder; int currentPosition = start + (end - start) / 2; while (start < end) { while ((start < currentPosition) && (array[start] <= array[currentPosition])) { start++; } while ((end > currentPosition) && (array[currentPosition] <= array[end])) { end--; } if (start < end) { int temp = array[start]; array[start] = array[end]; array[end] = temp; if (start == currentPosition) { currentPosition = end; } else if (end == currentPosition) { currentPosition = start; } } } privateSort(array, leftBorder, currentPosition); privateSort(array, currentPosition + 1, rightBorder); } private static void boundsTest(int arrayLength, int leftBorder, int rightBorder) { if (leftBorder < 0) { throw new ArrayIndexOutOfBoundsException("leftBorder index < 0: " + leftBorder); } if (rightBorder >= arrayLength) { throw new ArrayIndexOutOfBoundsException( "rightBorder index > number of arrays elements : " + rightBorder); } if (leftBorder > rightBorder) { throw new IllegalArgumentException("leftBorder > rightBorder which is illegal!"); } } }