1struct compare {
2 bool operator() (const int& x, const int& y) const {
3 return x<y; // if x<y then x will come before y. Change this condition as per requirement
4 }
5};
6int main()
7{
8 set<int,compare> s; //use the comparator like this
9}