//------------// Introduction to Programming Using Java: An Object-Oriented Approach//	Arnow/Weiss//------------// the sort method// Chapter 10, Section 10.7, Page 416-417// MODIFICATIONS://    sort is made static here so we//    can test it without creating an object//    main creates a Vector of Strings from input, invokes sort//	and then checks to see if it is sortedimport java.io.*;import java.util.*;class Testsort {	static void  exchange(Vector  v,  int  k,  int  j)  {		Object  obk = v.elementAt(k);		v.setElementAt(v.elementAt(j),k);		v.setElementAt(obk,j);	}	// Returns the index of the smallest element in v or -1 if none exist	static int  getSmallest(Vector  v,  int  k)  {		if  (v==null  ||  v.size()==k)			return  -1;		int i;		// Index of next element to examine; all elements at				//      positions less than k have been examined already.		int small;	// Index of smallest element examined so far		i  =  k+1;		small  =  k;		while  (i!=v.size())  {			String current  =  (String)  v.elementAt(i);			String  smallest  =  (String)  v.elementAt(small);			if  (current.compareTo(smallest)<0)				small  =  i;			i++;		}		// i==v.size()		return small;	}	static void sort(Vector  v) {	// On return, the elements of v are sorted in 					//       ascending order.		int k;	// k== the index of the next position in the Vector 			//       to take care of.			// All elements to the left of k are less than or 			//       equal to the elements at k or to the right of k.			// All elements to the left of k are in ascending 			//       order.		int n=v.size(); // n== number of elements in the Vector.		k = 0;		while  (k!=n-1)  {			int     j  =  getSmallest(v,k);			exchange(v,k,j);			k++;		}		// k==n-1 and therefore elements v[0], ..., v[n-2] are sorted; but because 		//      these elements are also less than the element in v[n-1] (the last 		//      element), the entire Vector is sorted.	}	static private boolean isSorted(Vector v) {		for (int i=0; i<v.size()-1;i++) {			String s1 = (String) v.elementAt(i);			String s2 = (String) v.elementAt(i+1);			if (s1.compareTo(s2) > 0)				return false;		}		return true;	}	public static void main(String[] a) throws Exception {		boolean fails=false;		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));		Vector v = new Vector();		String line = f.readLine();		String huge = "";		while (line != null) {			huge = huge.concat(line);			v.addElement(line);			line = f.readLine();		}		sort(v);		if (isSorted(v))			System.out.println("search passes these tests");		else			System.out.println("search fails these tests");	}}// Sample test input (must NOT be sorted!)// antidisestablishmentarianism// mustard// butter// butter// ketchup// z// x// abc