import java.util.Arrays;
import java.util.Collection;
public
class
QuickSort {
public
static
<T
extends
Comparable<T>> void myQuickSort(T[] t, int a,int b) {
if
(a < b) {
int q = Partition(t, a, b);
myQuickSort(t, a, q - 1);
myQuickSort(t, q + 1, b);
}
}
public
static
<T
extends
Comparable<T>> int Partition(T[] t, int a, int b) { int l = a; int r = b + 1;
T x = t[l];
while
(true) {
while
(t[++l].compareTo(x) < 0 && l < b);
while
(t[--r].compareTo(x) > 0);
if
(l >= r) {
break
;
}
swap(t, l, r);
}
t[a] = t[r];
t[r] = x;
return
r;
}
public
static
<T
extends
Comparable<T>> void swap(T[] data, int a, int b) {
T t = data[a];
data[a] = data[b];
data[b] = t;
}
public
static
void main(String[] args) {
Integer a[] = {0, 2, 2, 54, 1};
myQuickSort(a, 0, 4);
System.out.println(Arrays.toString(a));
}
}