Sorting Elements in a Sequence Using the sort algorithm - C++ STL Algorithm

C++ examples for STL Algorithm:sort

Description

Sorting Elements in a Sequence Using the sort algorithm

Demo Code

#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;
}

Result


Related Tutorials