C++ examples for STL Algorithm:sort
Sorting Elements in a Sequence Using the sort algorithm
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(int argc, char* argv[]) { vector<int> myVector{ 10, 6, 4, 7, 8, 3, 9 }; sort(myVector.begin(), myVector.end()); for (auto&& element : myVector) {/* w w w .j ava 2 s. c o m*/ cout << element << ", "; } cout << endl; return 0; }