1: //sort1a.cpp
3: #include <iostream>
4: #include <vector>
5: #include <algorithm>
6: using namespace std;
8: int main()
9: {
10: cout << "\nThis program illustrates the use of the STL sort() "
11: "algorithm (default version)\nto sort a vector of integers "
12: "into ascending order.";
13: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
15: int a[] = {17, 12, 14, 19, 23, 15, 61, 20, 81, 11};
16: vector<int> v(a, a+10);
18: cout << "\nHere are the original contents of the vector:\n";
19: for (vector<int>::size_type i=0; i<v.size(); i++)
20: cout << v.at(i) << " ";;
21: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
23: sort(v.begin(), v.end());
25: cout << "\nAnd here the sorted contents of the vector:\n";
26: for (vector<int>::size_type i=0; i<v.size(); i++)
27: cout << v.at(i) << " ";;
28: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
29: }