using system;
namespace quicksorter
{
public class quicksorter
{
private void swap(ref int l,ref int r)
{
int s;
s=l;
l=r;
r=s;
}
public void sort(int [] list,int low,int high)
{
int pivot;
int l,r;
int mid;
if(high<=low)
return;
else if(high==low+1)
{
if(list[low]>list[high])
swap(ref list[low],ref list[high]);
return;
}
mid=(low+high)>>1;
pivot=list[mid];
swap(ref list[low],ref list[mid]);
l=low+1;
r=high;
do
{
while(l<=r&&list[l]<pivot)
l++;
while(list[r]>=pivot)
r–;
if(l<r)
swap(ref list[l],ref list[r]);
}while(l<r);
list[low]=list[r];
list[r]=pivot;
if(low+1<r)
sort(list,low,r-1);
if(r+1<high)
sort(list,r+1,high);
}
}
public class mainclass
{
public static void main()
{
int[] iarrary=new int[]{1,5,3,6,10,55,9,2,87,12,34,75,33,47};
quicksorter q=new quicksorter();
q.sort(iarrary,0,13);
for(int m=0;m<=13;m++)
console.writeline("{0}",iarrary[m]);
}
}
}
