std::set<std::string> &uniq_email_list;
I have a set of many email elements, for examples:
('foo@bar.com', 'foo2@bar.com', 'foo@bazz.com', 'foo2@bazz.com','zfoo@bar.com')
then I write these elements to a file
for(iter = uniq_email_list.begin() ; iter!=uniq_email_list.end(); ++iter){
output_file<< *iter << std::endl;
}
Before I write these elements to the file, I want to sort by '@' next domain name and I want it to look like this in the file
foo@bar.com
foo2@bar.com
zfoo@bar.com
foo@bazz.com
foo2@bazz.com
And I know
You cannot resort a set, how it sorts is part of the type of the particular set. A given set has a fixed set order that cannot be changed.
You could create a new set with the same data relatively easily. Just create a new set that sorts based on the new criteria
I read that post Sorting Sets using std::sort But I couldn't find the answer to my problem.
As a result of my research I found something like
std::set<string>::iterator ⁢
it=myset.find('@');
Can I sort by the returned address with this structure? Or if there are other solutions suitable for this problem, thank you in advance, I am ready to get advice on issues related to C ++ solutions.