1vector <int> vect; //any container
2vector <int>::iterator start = vect.begin(), end=vect.end(); //iterator for the begin and end of the container
3sort (start,end); //std::sort (increasing order)
4sort (start,end,greater<int>()); //std::sort (decreasing order)
1sort(arr, arr+length); //increase
2sort(arr, arr+length, greater<int>()); //decrease
1 int arr[]= {2,3,5,6,1,2,3,6,10,100,200,0,-10};
2 int n = sizeof(arr)/sizeof(int);
3 sort(arr,arr+n);
4
5 for(int i: arr)
6 {
7 cout << i << " ";
8 }
9
1#include <iostream>
22 #include <array>
33 #include <string>
44 #include <algorithm>
55
66 using namespace std;
77
88 int main(){
99 array<string, 4> colours = {"blue", "black", "red", "green"};
1010 for (string colour : colours){
1111 cout << colour << ' ';
1212 }
1313 cout << endl;
1414 sort(colours.begin(), colours.end());
1515 for (string colour : colours){
1616 cout << colour << ' ';
1717 }
1818 return 0;
1919 }
2066
2120
2221 /*
2322 Output:
2423 blue black red green
2524 black blue green red
2625 */