title: Determines if the array list is sorted
body: <p>I need to estimate if the array list is sorted (don't sort). </p>
  
  <p>When Strings are sorted, they are in alphabetical order.
  I try to use <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#compareTo%28java.lang.String%29" rel="noreferrer">compareTo()</a> method to determine which string comes first</p>
  
  <p>And return true if the array list is sorted, else false.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>public boolean isSorted()
  {
      boolean sorted = true;        
      for (int i = 1; i &lt; list.size(); i++) {
          if (list.get(i-1).compareTo(list.get(i)) != 1) sorted = false;
      }
  
      return sorted;
  }
  </code></pre>
  
  <p><strong>Easy test:</strong></p>
  
  <pre><code>    ArrayList&lt;String&gt; animals = new ArrayList&lt;String&gt;();
      ArrayListMethods zoo = new ArrayListMethods(animals); 
      animals.add("ape");
      animals.add("dog");
      animals.add("zebra");
  
      //test isSorted
      System.out.println(zoo.isSorted());
      System.out.println("Expected: true");
  
      animals.add("cat");
      System.out.println(zoo.isSorted());
      System.out.println("Expected: false");
  
      animals.remove("cat");
      animals.add(0,"cat");
      System.out.println(zoo.isSorted());
      System.out.println("Expected: false");
  
      **Output:**
      false
      Expected: true
      false
      Expected: false
      false
      Expected: false
  </code></pre>
  
  <p>This easy test shows only <code>1/3</code> coverage.</p>
  
  <p>How to solve this issue.</p>