Have you included string, vector and algorithm header files. I copied and pasted the code too, its working perfectly fine for me. I am pasting the code below. Try this:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{ vector <string> v; string s;
while (1)
{
cout << " Enter lines of text that you want to sort:\n";
getline(cin,s);
if ( s == "stop")
break;
v.push_back(s);
}
sort(v.begin(), v.end());
cout << " After sorting: \n";
for (int i=0; i < v.size(); i++)
cout << v[i] << endl;
return 0;
}