title: QuickSort descending order
body: <p>I am trying to implement QuickSort in a descending order. I have tried to trace through my code to see why it is only partially-sorted. My input was an int array of: {3,4,6,1,9,7}. After sorting, I got {9,4,7,6,3,1}, where 4 is not in the correct place.</p>
  
  <pre><code>    public int partition(int arr[], int left, int right)
      {
         int pivot = arr[right];
         int i = left - 1;
         for(int j = right; j &gt;= left; j--)
      {
          if (arr[j] &gt; pivot)
          {
              i = i + 1;                                      
              int temp = arr[i];
              arr[i]= arr[j];
              arr[j]= temp;
          }
      }
  
      int temp = arr[i+1];
      arr[i+1] = arr[right];
      arr[right] = temp;
  
      return i + 1;
  
      }
  
  public void sorting(int arr[], int left, int right)
  {
      if(left &lt; right)
      {
          int q = partition(arr, left, right);
          sorting(arr, left, q - 1);
          sorting(arr, q + 1, right);
      }
  }
  </code></pre>