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
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3773 |
3 | Radewoosh | 3646 |
4 | ecnerwala | 3624 |
5 | jqdai0815 | 3620 |
5 | Benq | 3620 |
7 | orzdevinwang | 3612 |
8 | Geothermal | 3569 |
8 | cnnfls_csy | 3569 |
10 | gyh20 | 3447 |
# | User | Contrib. |
---|---|---|
1 | awoo | 161 |
2 | maomao90 | 160 |
3 | nor | 157 |
4 | atcoder_official | 156 |
4 | cry | 156 |
6 | -is-this-fft- | 155 |
7 | maroonrk | 154 |
8 | adamant | 153 |
9 | Um_nik | 151 |
10 | djm03178 | 146 |
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
Name |
---|
Auto comment: topic has been updated by Medeali (previous revision, new revision, compare).
You have to define
operator <
for your struct or pass a custom comparator tosort
.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});