title: Implementing Wikipedia in-place quicksort pseudocode in Java
body: <p>I'm using the pseudocode called Lomuto partition scheme on <a href="https://en.wikipedia.org/wiki/Quicksort" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Quicksort</a>. But I just don't understand what it is that I am doing wrong here. The array never gets organized (regardless of the input size). This is preparation for my final exam. My professor wants us to use this algorithm, but I can't just learn it unless I have an understanding of how it works by testing it.</p>
  
  <pre><code>private static void quickSort(Integer A[], int l, int r) {
  
      if (l &lt; r) {
          int k = partition(A, l, r);
          quickSort(A, l, k - 1);
          quickSort(A, k + 1, r);
      }
  }
  
  private static int partition(Integer A[], int l, int r) {
      int pivot = A[r];
      int i = l;
  
      for (int j = l; j &lt;= r - 1; j++) {
          if (A[j] &lt;= pivot) {
              i++;
              int temp = A[j];
              A[j] = pivot;
              pivot = temp;
          }
      }
  
      int temp = A[i + 1];
      A[i + 1] = A[r];
      A[r] = temp;
  
      return i + 1;
  }
  </code></pre>