I have a program that takes customer information ( such as name, address, city and state ect....) from a disk file and loads it into a vector. Each element of the vector is a struct like this.
The elements that are saved on disk are in no particular order but I want to be able to sort the vector in alphabetical order to display to the screen. I was thinking about creating a header file with a class called sort to do the dirty work. Can I pass a pointer to the entire vector to this sort class and return a pointer to the new sorted vector back to the program? If so, is the pointer syntax the same and how do I dereference it to replace the old vector with the new sorted vector?Code:struct mystruct
{
string name;
string address;
string city;
string state;
string zip;
string phone;
};
mystruct customers;
I know there are functions such as sort that can do this for me but I want to a sort by city, then sort those by name. Plus, I just want to see if I can do it :D