Answers for "sort implementation c++"

C++
2

c++ sort code

vector <int> vect; //any container
vector <int>::iterator start = vect.begin(), end=vect.end(); //iterator for the begin and end of the container
sort (start,end); //std::sort (increasing order)
sort (start,end,greater<int>()); //std::sort (decreasing order)
Posted by: Guest on August-22-2021
0

c++ sort

#include<bits/stdc++.h>

vector<int> v = { 6,1,4,5,2,3,0};
sort(v.begin() , v.end()); // {0,1,2,3,4,5,6} sorts ascending
sort(v.begin(), v.end(), greater<int>()); // {6,5,4,3,2,1,0} sorts descending
Posted by: Guest on May-05-2021

Code answers related to "sort implementation c++"

Browse Popular Code Answers by Language