public class SpeedSort {
private int[] a;public void sort() {
int begin = 0; int end = a.length - 1; quickSort(begin, end); for (int i : a) { System.out.print(i + " "); } }private void quickSort(int begin, int end) {
if (begin >= end) {} else {
int pivot = a[end]; int result = getPivot(begin, end, pivot); quickSort(begin, result - 1); quickSort(result + 1, end); }}
private int getPivot(int begin, int end, int pivot) {
begin = begin - 1; int o = end; while (true) { while (a[++begin] < pivot) {}
while (end > 0 && a[--end] > pivot) {}
if (begin >= end) { break; } else { swap(begin, end); } } swap(begin, o); return begin; }private void swap(int begin, int end) {
int t = a[begin]; a[begin] = a[end]; a[end] = t; }public int[] getA() {
return a; }public void setA(int[] a) {
this.a = a; }}