/**
* 快速排序
*
* @param list
*/
public static void fastSorted(int[] list, int i, int j) {
if (i >= j) {
return;
}
int needToSortLen = j;
int referIndex = i;
while (i != j) {
while (list[referIndex] <= list[j] && j > i) { j--;}
while (list[referIndex] >= list[i] && i < j) { i++;}
int temp = list[j];
list[j] = list[i];
list[i] = temp;
}
int tempReferValue = list[referIndex];
list[referIndex] = list[i];
list[i] = tempReferValue;
fastSorted(list, referIndex, i - 1);
fastSorted(list, i + 1, needToSortLen);
}
参考链接:http://developer.51cto.com/art/201403/430986.htm