title: Selection Sort with an ArrayList of objects
body: <p>I'm having some trouble with this sort. It will only display the first file correctly in order. Anyone see what I'm doing wrong? I've been trying to figure it out for hours now and just don't see what I'm doing wrong.</p>
  
  <pre><code>public void sort() { 
  
      int i; //loop control
      int last; //last position in the arraylist
      int max; //position where last alphabetical filename is found
  
      max = 0; //largest position so far is first, since i haven't checked
  
      //I thought i should start at the end and work my way down
      for(last = fileList.size()-1; last &gt;= 0; last--) {
  
          for(i = 0; i &lt; fileList.size(); i++) {
              if(fileList.get(max).getFileName().compareTo(fileList.get(i).getFileName()) &gt; 0)
                  max = i;
          }
  
          //swap pixfile in last position with the last alphabetical
          Pixfile tempPix = fileList.get(last);
          fileList.set(last, fileList.get(max));
          fileList.set(max, tempPix);
          //i thought i would repeat until last = 0 and the arraylist is sorted
      }//end for
  
  }
  </code></pre>