Sort part of the elements in an array

Started by aruljothi, Jun 11, 2009, 07:44 PM

Previous topic - Next topic

aruljothi

#include <iostream>
#include <algorithm>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int coll[] = { 5, 6, 2, 4, 1, 3 };

    // sort beginning with the second element
    sort (coll+3, coll+6);

    // print all elements
    copy (coll, coll+6,ostream_iterator<int>(cout," "));
    cout << endl;
}