Anyone can help me to sort this code alphabetically ?

Anyone can help to sort this code alphabetically ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void displayAll()
{
	string costumerF, costumerL, firstAlph, lastAlph;// costumers;
	ifstream directory;
	string filename = "directory.txt";
	directory.open("directory.txt");

	while (directory >> costumerL >> costumerF)
	{
		cout << costumerL << ' ' << costumerF << endl;
	}

	directory.close();

	//cout << "First Name By Alphabet is: " << firstAlph << endl;
	//cout << "Last Name By Alphabet is: " << lastAlph << endl;
}
you could use a STL-container like std::vector to store the names and std::sort for sorting them

or you could compare the lastAlph and firstAlph each time with the new input...
so many possibilities :o
Last edited on
Topic archived. No new replies allowed.