// Sort a list of names in a vector
// By DreamVB 18:58 17/10/2016

#include <iostream>
#include <vector>
#include <algorithm>
#include <time.h>

using namespace std;
using std::cout;
using std::endl;

bool FirstLetterCompare(string i, string j)
{
	return (i[0]<j[0]);
}

int main(int argc, char *argv[]){
	vector<string>Names = { "Paul","John","Bob","Fred","Geroge","Ben",
		"Sid","Jack","Dave","Gemma","Kate","Stacy","Jane","Zoe","Pete","Harry" };
	int i = 0;
	
	//Print out vector items in unsorted sorder.
	cout << "Unsorted vector" << endl;
	while (i < Names.size()){
		cout << Names[i].c_str() << " ";
		i++;
	}
	cout << endl;
	i = 0;
	//Sort the vector in acending order
	std::sort(Names.begin(), Names.end(), FirstLetterCompare);

	//Print sorted vector.
	cout << "Sorted vector" << endl;

	while (i < Names.size()){
		cout << Names[i].c_str() << " ";
		i++;
	}
	cout << endl;
	system("pause");
	return 0;
}