title: Writing a recursive sorting algorithm of an array of integers
body: <p>I am trying to write a recursive sorting algorithm for an array of integers. The following codes prints to the console: 3, 5, 2, 1, 1, 2, 6, 7, 8, 10, 20 </p>
  
  <p>The output should be sorted but somehow "it doesn't work".</p>
  
  <pre><code>public static void main(String[] args)
  {
      int[] unsortedList = {20, 3, 1, 2, 1, 2, 6, 8, 10, 5, 7};
      duplexSelectionSort(unsortedList, 0, unsortedList.length-1);
  
      for (int i = 0; i &lt; unsortedList.length; i++)
      {
          System.out.println(unsortedList[i]);
      }
  }
  
  
  public static void duplexSelectionSort(
      int[] unsortedNumbers,
      int startIndex,
      int stopIndex)
  {
      int minimumIndex = 0;
      int maximumIndex = 0;
  
      if (startIndex &lt; stopIndex)
      {
          int index = 0;
          while (index &lt;= stopIndex)
          {
              if (unsortedNumbers[index] &lt; unsortedNumbers[minimumIndex])
              {
                  minimumIndex = index;
              }
              if (unsortedNumbers[index] &gt; unsortedNumbers[maximumIndex])
              {
                  maximumIndex = index;
              }
              index++;
          }
          swapEdges(unsortedNumbers, startIndex, stopIndex, minimumIndex, maximumIndex);
          duplexSelectionSort(unsortedNumbers, startIndex + 1, stopIndex - 1);
      }
  }
  
  
  public static void swapEdges(
      int[] listOfIntegers,
      int startIndex,
      int stopIndex,
      int minimumIndex,
      int maximumIndex)
  {
      if ((minimumIndex == stopIndex) &amp;&amp; (maximumIndex == startIndex))
      {
          swap(listOfIntegers, startIndex, stopIndex);
      }
      else
      {
          if (maximumIndex == startIndex)
          {
              swap(listOfIntegers, maximumIndex, stopIndex);
              swap(listOfIntegers, minimumIndex, startIndex);
          }
          else
          {
              swap(listOfIntegers, minimumIndex, startIndex);
              swap(listOfIntegers, maximumIndex, stopIndex);
          }
      }
  }
  
  public static void swap(int[] listOfIntegers,
      int index1,
      int index2)
  {
      int savedElementAtIndex1 = listOfIntegers[index1];
      listOfIntegers[index1] = listOfIntegers[index2];
      listOfIntegers[index2] = savedElementAtIndex1;
  }
  </code></pre>