public class sort1
{
// Bubble sort
public static void bubblesort(double A[])
{
int n=A.length;
double hold;
int i,j; 
boolean switched = true;
for (i=0; i<n-1 && switched; i++)
{
  switched = false;
  for(j=0; j<n-i-1; j++)
  {if (A[j] > A[j+1])
   { switched = true;
     hold = A[j];
     A[j] = A[j+1];
     A[j+1] = hold;
   }
  }
}
}

//Straight selection sort
public static void selectsort(double A[])
{
int n=A.length;
double large;
int i,j, indx;
for(i=n-1; i>0; i--)
{  large = A[0];
   indx = 0;
   for(j=1; j<=i; j++)
   if(A[j]>large)
     { large = A[j];
       indx = j;
     }
   A[indx] = A[i];
   A[i] = large;
}
}
//Insertation sort
// Adding elements to a list
public static void insertsort(double A[])
{
int n=A.length;
int i,k;
double y;
for(k=1; k<n; k++)
{
y=A[k];
for(i=k-1; i>=0 && y<A[i]; i--)
A[i+1]=A[i];
A[i+1]=y;
};
}
//quick sort
public static void quickSort(double A[])
{
int p=0;
int r=A.length-1;
quickSort(A,p,r);
}
	
public static void quickSort(double A[],int p, int r)
{	
	int q;
    if(p<r)
    {
        q=partition(A,p, r);
        quickSort(A,p, q-1);
        quickSort(A,q+1, r);
    }
}

public static int partition(double A[],int p, int r){
    double tmp;
    double x = A[r];
    int i = p-1;

    for(int j=p; j<=r-1; j++)
    {
        if(A[j]<=x)
        {
            i++;
            tmp=A[i];
            A[i]=A[j];
            A[j]=tmp;
        }
    }
    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;
    return i+1;
}

public static void main(String arg[])
{double a[]={88,31,52,25,98,14.1,30,62,23,79 };
quickSort(a,0,a.length-1);
System.out.println(Matrix.toStringT(a));
}
}