Hi I have vector of strings,that is the structure of vector : The name of vector is vector
"key: abc 165.123.34.12",
"key: bca 1.1.1.1",
"key1: bac 3.3.3.3"
I want to sort the vector according to the second field(abc,bac,bac)
My code is;
bool sort_function(string& str1,string& str2) {
string nick1,nick2,nick1_ignore,nick2_ignore;
stringstream ss1(str1)
ss1>> nick1_ignore >> nick1;
stringstream ss2(str2)
ss2>> nick2_ignore >> nick2;
return (nick1<nick2);
}
sort(vector.begin(), vector.end(),sort_function);
But it gives a long error starting with error,
error: no match for ‘operator>>’ in ‘std::basic_stringstream<char>
UPDATE:Error is tl_algo.h: In function ‘_RandomAccessIterator std:..
UPDATE:It is fixed. the error is in function declaration I have to use const string