      // At this point, theArray[n+1-pass..n−1] is sorted
      // and all of its entries are > the entries in theArray[0..n–pass]
      sorted = true; // Assume sorted
      for (int index = 0; index < n − pass; index++)
      {
         // At this point, all entries in theArray[0..index–1]
         // are <= theArray[index]
         int nextIndex = index + 1;
         if (theArray[index] > theArray[nextIndex])
         {
            // Exchange entries