I read an article in geekforgeeks for sorting in a particular order (vector). This is the code that I got from the site.
You can see the output is correct below in the image. This is my code now
#include<bits/stdc++.h>
using namespace std;
bool max(int a, int b)
{
return (a < b);
}
int main()
{
vector<int> v;
cout<<"Current size is "<<v.size()<<"\nPutting elements now\n";
for(int i=0;i<10;i++)
v.push_back(rand()%1000);
//sort(v.begin(),v.end(),greater<int>());
sort(v.begin(),v.end(),max);
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
return 0;
}
I get this error
error: no matching function for call to 'sort(std::vector<int>::iterator, std::vector<int>::iterator, <unresolved overloaded function type>)'
sort(v.begin(),v.end(),max);
PS: I know about using greater <int> ()
Thanks in advance :)