Sorting by name from text file

For a class assignment we were given multiple files and told to make a menu and create 3 functions. One show all student data from text file, one just shows the first and last name and the other to sort by student name. Instructions were as follows: simplest type of sort to implement may involve creating a new blank array on the heap, finding the earliest name left in the primary array, and repeating until the temporary array is full. I think I have the first two correct but could use help on the sort. I'm relatively inexperienced with c++ but this is what I have.

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
  #include <sstream>
#include <iostream>
#include <fstream>
#include "Date.h"
#include "Address.h"
#include "student.h"


using namespace std;

int main(){

	string line;
	ifstream inputFile("studentdata.txt");
	bool keepGoing = true;
	Student *student = new Student[50];
	int i = 0;
	while(!inputFile.eof()){
		getline(inputFile, line);
		student[i].setInfo(line);
		i++;
	}
	int choice;
	cout << "A Heap of Students";
	while(keepGoing){ //This while loop creates the menu and asks for user input
		cout << "What would you like to do?" << endl;
		cout << "1. Print full report." << endl;
		cout << "2. Print simple report." << endl;
		cout << "3. Sort records." << endl;
		cout << "4. Quit" << endl;
		cin >> choice;

        //prints full student report
		if(choice == 1){
			for(int i = 0; i < 50; i++){ //Full print loop
				cout << student[i] << endl;
			}
			cout << endl;
			keepGoing = true;
		}
		//Just first and last name
		else if(choice == 2){
			cout << "First Last" << endl;
			for(int i = 0; i < 50; i++){
			cout << student[i].getFirstName() << " " << student[i].getLastName() << endl;
			}
			cout << endl; //formatting
			keepGoing = true;
		}
		//sort function by name

		}
		//quit
		else if(choice == 4){
		    cout << "Goodbye!" << endl;
			keepGoing = false;
		}
	}
		return 0;
}
Topic archived. No new replies allowed.