public class FastSort {
public static void main(String[] args) {
int[] array = new int[]{2,1,5,3,4};
FastSort.sort(array,0,array.length-1);
for(int i:array){
System.out.print(i+" ");
}
}
static void sort(int[] param,int fast,int end){
int l = fast;
int h = end;
int target = param[fast];
if(h<l){
return;
}
while(l<h){
while(l<h&¶m[h]>=target)
h--;
if(l<h){
int temp = param[h];
param[h] = param[l];
param[l] = temp;
l++;
}
while(l<h&¶m[l]<=target)
l++;
if(l<h){
int temp = param[h];
param[h]=param[l];
param[l]=temp;
h--;
}
}
if(l>fast)sort(param,fast,l-1);
if(h<end)sort(param, l+1, end);
}
}
public static void main(String[] args) {
int[] array = new int[]{2,1,5,3,4};
FastSort.sort(array,0,array.length-1);
for(int i:array){
System.out.print(i+" ");
}
}
static void sort(int[] param,int fast,int end){
int l = fast;
int h = end;
int target = param[fast];
if(h<l){
return;
}
while(l<h){
while(l<h&¶m[h]>=target)
h--;
if(l<h){
int temp = param[h];
param[h] = param[l];
param[l] = temp;
l++;
}
while(l<h&¶m[l]<=target)
l++;
if(l<h){
int temp = param[h];
param[h]=param[l];
param[l]=temp;
h--;
}
}
if(l>fast)sort(param,fast,l-1);
if(h<end)sort(param, l+1, end);
}
}