public class ThreeSorter
{
   private int[] a;

   public ThreeSorter(int[] anArray)
   {
      a = anArray;
   }

   public void sort()
   {
      // ...
   }

   /**
      Sorts the three elements a[start], a[start + 1], a[start + 2].
      If start > a.length - 3, sorts the one or two remaining elements.
   */
   public void sortThree(int start)
   {
      // ...
   }

   /**
      Checks whether the array managed by this sorter is sorted.
      @return true if the array is sorted
   */
   public boolean isSorted()
   {
      // ...
   }

   /**
      Swaps two entries of the array.
      @param i the first position to swap
      @param j the second position to swap
   */
   private void swap(int i, int j)
   {
      int temp = a[i];
      a[i] = a[j];
      a[j] = temp;
   }
}
