title: Method cannot access the sorted array
body: <p>The following code sorts through a dictionary of words in lexicographical order. The problem is that I cannot access the sorted array outside of the for loop. Well I think this is the problem. I have declared the array words in another method and returned it to a private variable within the same class. But after I sort the array and try to print it out, it just prints out the original array. I also want to mention that this sorting method does work as I have tested it in another class where everything was in the main method. So again I believe my problem has to do with returning the new sorted array. I also need to write a few lines of code within the method after the array is sorted and when I tried to return the array, using "return words;" I was unable to write this code.</p>
  
  <pre><code>public void insertionSort() {
  int in, out;
  
  for (out=1; out&lt;nElems; out++){
      String temp = words[out];                               // remove marked item
      in = out;                                               // start shifting at out                
  
      while (in&gt;0 &amp;&amp; words[in-1].compareTo(temp)&gt;0){          // until temp is lexicographically after after the word it is being compared to
          words[in] = words[in-1];                            // shifts word to next position in lexicographical order
          --in;                                                   
      }
      words[in] = temp;
  }
  for(int i=0; i &lt;words.length; i++)
      System.out.println(words[i]);
  </code></pre>