vector<int> vec;
generate_n(back_inserter(vec),100,rand);
sort(vec.begin(),vec.end());//or sort(vec.begin(),vec.end(),greater<int>());
copy(vec.begin(),vec.end(),ostream_iterator<int>(cout," "));
#include <iostream>
#include <functional>
#include <algorithm>
#include <iterator>
#include <vector>
#include <cstdlib>
using namespace std;
int main(int argc,char** argv)
{
vector<int> vec;
generate_n(back_inserter(vec),100,rand);
copy(vec.begin(),vec.end(),ostream_iterator<int>(cout," "));
cout<<endl;
sort(vec.begin(),vec.end());
copy(vec.begin(),vec.end(),ostream_iterator<int>(cout," "));
cout<<endl;
system("pause");
return 0;
}