title: Insertion Sort using string.compareTo()
body: <p>As far as I can tell, I have implemented the basic insertion sort here. The output is the same array, unsorted. Am I making use of compareTo correctly? I am unsure what it means by being some number greater than or less than zero.</p>
  
  <pre><code>import java.util.Arrays;
  
  public class Test {
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
      int lineNumber = 5;
      int i,j;
      String key;
      String[] inputArray = {"E","D","C","B","A","B"};
      System.out.println(Arrays.toString(inputArray));
      for (j = 1; j &lt; lineNumber; j++) {
          key = inputArray[j];
          i = j - 1;
          while (i &gt;= 0) {
              if (key.compareTo(inputArray[i]) &lt; 0) {
                  break;
              }
              inputArray[i + 1] = inputArray[i];
              i--;
          }
          inputArray[i + 1] = key;
          System.out.println(Arrays.toString(inputArray));
      }
      System.out.println(Arrays.toString(inputArray));
  }
  </code></pre>
  
  <p>run:</p>
  
  <pre><code>[E, D, C, B, A, B]
  
  [E, D, C, B, A, B]
  
  [E, D, C, B, A, B]
  
  [E, D, C, B, A, B]
  
  [E, D, C, B, A, B]
  
  [E, D, C, B, A, B]
  
  BUILD SUCCESSFUL (total time: 0 seconds)
  </code></pre>