// wordsort
// Purpose: read a list of words from the keyboard, print them
//			and sort them.
// Author: Mark Sebern
// Version: 1.00
// Created: 24 October 1997

#include <iostream>		// Input/output library
#include <string>		// Character string library
#include <vector>		// Vector container
#include <algorithm>	// STL algorithms (including sort)
using namespace std;

// The following compiler directive (pragma) suppresses an annoying
// warning message that results when long internal names are generated
// by template expansion. It has no effect on the actual program.
#pragma warning (disable:4786)

void main ()
{
	vector <string> words;		// Vector of words.

	string input_word;			// Next word read from input.

	cout << "Enter list of words, followed by END" << endl;

	cin >> input_word;
	while (input_word != "END")
	{
		words.push_back (input_word);
		cin >> input_word;
	}

	// Get the number of words in the vector.
	unsigned int num_words = words.size();
	// Define a data object to use as a subscript into the vector.
	unsigned int index = 0;

	// Loop through vector contents, accessing individual words
	// with the subscript operator. Print the words one per line.
	cout << "Words in original order:" << endl << endl;
	for (index = 0; index < num_words; index++)
	{
		cout << words [index] << endl;
	}
	cout << endl;

	// Sort all the words (from beginning to end) in the vector.
	sort (words.begin(), words.end());

	// Print out the (sorted) words, as before.
	cout << "Sorted words:" << endl << endl;
	for (index = 0; index < num_words; index++)
	{
		cout << words [index] << endl;
	}

}