title: java insertion sort recursive
body: <p>i have an array and have to sort them using insertion sort. i tried to use the compareTo method to run through the array and see whats bigger. I ran into a problem because i was trying to reference an array index with a string which obviously didntwork (thats at compareTo(a[key])).</p>
  
  <p>any suggestions or hints as to how to do this would be appreciated.</p>
  
  <p>this is what i have so far. is it a good start? or a start in the right direction?</p>
  
  <pre><code> public void insertionSort() 
      { 
          insertionSort(a.length-1);
      } 
  
  
  
      private void insertionSort(int n)
      {
          String temp; 
          if(n &lt;= 1)
          {
          //Do nothing, easiest case
          }
  
          else
          {
          for(int i = 1; i &lt; a.length; i++)
          {
          int j;
          String key = a[i];
  
              while((j &gt;= 0) &amp;&amp; (a[i].compareTo(a[key]) &gt; 0))
              {
              a[i+1] = a[i];
              j--;
              }
              a[i+1] = key;
          }   
  
          insertionSort(n-1);
  
          }
      } 
  </code></pre>