private static int indexOfLargest(Comparable[] theArray, 
                                  int size) {
// ---------------------------------------------------
// Finds the largest item in an array.
// Precondition: theArray is an array of size items;
// size >= 1.
// Postcondition: Returns the index of the largest 
// item in the array.
// ---------------------------------------------------
  int indexSoFar = 0; // index of largest item found so far
  // Invariant: theArray[indexSoFar]>=theArray[0..currIndex-1]
  for (int currIndex = 1; currIndex < size; ++currIndex) {  
    if (theArray[currIndex].compareTo(theArray[indexSoFar])>0) { 
      indexSoFar = currIndex;
    }  // end if
  } // end for
  
  return indexSoFar;  // index of largest item
}  // end indexOfLargest
