What if i want to use sort function

What if I want to use sort function in descending order of lexicographical manner

e.g app, dpp, cop using sort function sort(s,s+n)
will return app,cop,dpp

but if I want it in reverse order what is the code.

@Souradeep-Kundu-824545687968212
hello Souradeep ,

u can do it by two ways
a) using inbuilt comparator greater < string >()

  • sort(s,s+n,greater < string >() )

b) or u can pass ur own comparator.

  • bool cmp(string s1,string s2){ //declaring comparator
    return s1 > s2;
    }
  • sort(s,s+n,cmp )