private static long doWork(Sort12 sorter, String document, int numwords,
			boolean doPrint ) {
		long start, end;
		
		// now read in words
		int nwords = 0;
		ArrayList<String>  unsorted = new ArrayList<String>(numwords);
		
		// get the start time
		long totalTime = 0;
		
		try {

			// open up the document
			FileInputStream in = new FileInputStream(document);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;
			
			// make sure we are ready to go
			unsorted.clear();
			
			String line;
			// read in the document
			while((line = br.readLine())!= null && nwords < numwords)
			{
				String[] arr = line.split( " " );
				for ( String word : arr ) {
					word = SortTimer2.trimPunctuation(word);
					unsorted.add(nwords++, word);
					if (DEBUG) {
						if (nwords %1000 == 0 ) {
							System.out.printf("\rRead in %d words", nwords);
						}
					}
				}
			}
    	} catch (IOException e) {
			System.out.println("problem reading from wordlist:" + e.getMessage());
			return 0;
    	}
	
		// get the start time 
		start = System.currentTimeMillis();
		sorter.sort(unsorted);
		// get the end time 
		end = System.currentTimeMillis();
		// count the number of milliseconds elapsed
		totalTime += ( end-start );
		if (doPrint)
		{
			Iterator<String> iter = unsorted.iterator();
			while (iter.hasNext())	
				System.out.println(iter.next());
		}
			
		return totalTime;
		
	}