title: What is the time complexity for this sort algorithm?
body: <p>Explaning better</p>
  
  <p>I have the following problem, I have source array of integer values, then I need to order the source array by suffix comparator and put it a sorted array, The problem is that I want to know which is the time complexity of constructing the suffix-array(sorting the source array) </p>
  
  <p>This is the method sort:</p>
  
  <pre><code>Collections.sort(sorted, new SuffixComparator&lt;Integer&gt;(source));
  </code></pre>
  
  <p>and this is the class SuffixComparator:</p>
  
  <pre><code>public class SuffixComparator&lt;Type extends Comparable&lt;Type&gt;&gt; 
  implements java.util.Comparator&lt;Integer&gt; {
  List&lt;Type&gt; array1;
  List&lt;Type&gt; array2;
  
  /**
   * Constructor with a single array
   */
  public SuffixComparator (ArrayList&lt;Type&gt; array) {
  array1 = array;
  array2 = array;
  } 
  
  /**
   * Constructor with two arrays
   */
  public SuffixComparator (List&lt;Type&gt; a1, List&lt;Type&gt; a2) {
  array1 = a1;
  array2 = a2;
  }  
  
  /**
   * Constructor with two arrays
   */
  public SuffixComparator (ArrayList&lt;Type&gt; a1, ArrayList&lt;Type&gt; a2) {
  array1 = a1;
  array2 = a2;
  }
  
  /**
   * Compare two suffixes 
   * @param offset1 first offset
   * @param offset2 second offset
   */
  public int compare (Integer offset1, Integer offset2) {
  int result;
  if ( array1 == array2 &amp;&amp; offset1.equals(offset2) ) {
      result = 0;
  } else {
      int n1 = offset1;
      int n2 = offset2;
      while (n1 &lt; array1.size() &amp;&amp; 
         n2 &lt; array2.size() &amp;&amp; 
         array1.get(n1).equals(array2.get(n2))) {
      ++n1;
      ++n2;
      }
      if (n1 == array1.size()) {
      result = (n2 &lt; array2.size()) ? -1 : 0;
      } else if (n2 == array2.size()) {
      result = 1;
      } else {    // n1 &lt; array1.size &amp;&amp; n2 &lt; array2.size
      result = array1.get(n1).compareTo(array2.get(n2)); 
      }
  } 
  return result;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Any suggestions?</p>