Bubble sort string vector

ive been working on this for a while and I'm at the point where I'm required to bubble sort my string vector. I looked everywhere on how to do this but no luck..
I'm trying to sort the names of the volunteers by getting the last name to be listed first and then first name. my issue is, is that I have no idea how to get it to sort. be aware that I have objects and header files. this is the portion of my main.

also to note I need the sort to be in a function out side of main.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  
#include <iostream>
#include <string>
#include <fstream>
#include <vector>

#include "VolunteerNumber.h"

using namespace std;

int main()
{
	//create vector 
	vector <string> mVector;
		//Declare variables
	string
		nameVolGr,	//Name of volunteer group 
		nameLoc,	//Name of location of the volunteer group
		fileName,	//name of output file
		clocation,	//loction of output file 
		nameF,		//stores first name
		nameL,		//stores last name
		email,		//stores email
		phone,		//stores phone number
		data;		//stores concat
	int numVol;		//stores number of volunteers
	 
		//Ask user for volunteer group name
	cout << "Volunteer Group Name: ";
	cin >> nameVolGr;
		//Ask user for location
	cout << "Location: ";
	cin >> nameLoc;
		//Ask for number of volunteers
	cout << "Number of Volunteers: ";
	cin >> numVol;

		//Creat output file
	fileName = clocation + "_" + nameVolGr + ".txt";
	ofstream fout(fileName);
	
		//for loop to count till the number of volunteers on the list id met
	for (int i = 1; i <= numVol; i++)
	{
		//ask user in loop for information
		cout << "-----------------------------------" << endl;
		cout << "To end program enter -1 in first name" << endl << endl;
		
		
		//Ask user to enter volunteers first name
		//this is out side the if so the user can end using -1 inside first name
		cout << "Enter first name: ";
		cin >> nameF;
			
		//if statement
		if (nameF != "-1")
		{
			//Ask user to enter volunteers last name
			cout << "Enter enter last: ";
			cin >> nameL;
			//Ask user to enter volunteers email address
			cout << "Enter email: ";
			cin >> email;
			//Ask user to enter volunteers phone number
			cout << "Enter phone number: ";
			cin >> phone;
		}
		else
		{
			break;
		}

		//Get volunteer information
		VolunteerNumber group_1(nameF, nameL, email, phone);

		//display information that was added
		cout << endl << "Fist name: " << group_1.getNameF() << endl <<
			"Last name:  " << group_1.getNameL() << endl <<
			"Email: " << group_1.getemail() << "Phone #: " << group_1.getphone() << endl;
		


		//concat data all together in to data variable
		data = nameL + "	" + nameF + "	" + email + "		" + phone;
		//push data variables into mVector 
		mVector.push_back(data);
		//reset variables
		data = "";
	}
	//print vector data
	for (int i = 0; i < mVector.size(); i++)
	{
		cout << mVector[i] << endl;
	}

	system("pause");
	return 0;
}
Topic archived. No new replies allowed.