Can't understand why my sort algorithm is so slow
<p>So I'm playing around with quick sort and I've noticed something strange, anytime I go over 10 values to sort, the sorting takes a VERY long time, compared to something like insertion sort. Can someone explain why it so so slow anytime I ask it to sort more than 10 values? Maybe it's something to do with the code. </p>

<p>EDIT. I've made some changes and now I'm getting stack overflow errors, great. </p>

<pre><code>       public class quicksorttest{
   public static void main(String args[]){
      int array[] = new int[100];
      for(int a =0; a&lt;array.length;a++){
         array[a] = (int)(Math.random()*100);
      }

      quickSort(array,0,array.length);
   }

   public static void quickSort(int array[],int p, int q){
    if(q-p &lt;=1);//skip

    else{
        int x; int i,j,k;
        //let x = middle element in f[p..q-1]. 

        x= array[(p+q/2)];
        i=p;j=p;k=q;
        while(j!=k){
            if(array[j]==x)
                j=j+1;
            else if(array[j]&lt;x){    //swap array[j] with array[i]
                int temp =array[j];
                array[j] = array[i]; array[i]=temp;
                j=j+1;i=i+1;

            }
            else{//array[j]&gt;x
                //swap array[j[ with array[k-1]
                int temp = array[j]; 
                array[j] = array[k-1]; array[k-1]=temp;
                k=k-1;
            }
        }

        quickSort(array,p,i);
        quickSort(array,j,q);

    }
   }
}
</code></pre>
