Medeali's blog

By Medeali, history, 2 weeks ago, In English

i am trying to sort an array of structs but i am getting compiling error this is my code https://ideone.com/mQPPxI could someone help me solve the issue please

  • Vote: I like it
  • -4
  • Vote: I do not like it

»
2 weeks ago, # |
  Vote: I like it -8 Vote: I do not like it

Auto comment: topic has been updated by Medeali (previous revision, new revision, compare).

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

You have to define operator < for your struct or pass a custom comparator to sort.

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

you cannot just do that .

An easy solution is just to add a comparator to sort

sort(A,A+n,[&](querie a , querie b){ return a.f>b.f});