public class QuickSort { public int getMiddle(int[] list,int low,int high) { int temp = list[low]; while(low < high) { while(low < high && list[high] >= temp) { high--; } list[low] = list[high]; while(low < high && list[low] <= temp) { low++; } list[high] = list[low]; } list[low] = temp; return low; } public int[] quickSort(int[] list,int low,int high) { if(low < high) { int middle = getMiddle(list,low,high); quickSort(list, low, middle); quickSort(list, middle+1, high); } return list; } public static void main(String args[]) { int a[] = { 49, 38, 65, 97, 76, 13, 27, 49, 78, 34, 12, 64, 5, 4, 62, 99, 98, 54, 56, 17, 18, 23, 34, 15, 35, 25, 53, 51 }; int[] result = new QuickSort().quickSort(a, 0, a.length-1); for(int i=0;i<result.length;i++) { System.out.println(result[i]); } } }