uttom's blog

By uttom, history, 7 years ago, In English

Problem Accepted Solution Runttime error code

I sort some value that are stored in some vector(2D) lst[]

bool cmp(i64 a,i64 b){
 return a>b
}
sort(lst[i].begin(),lst[i].end(),cmp)

This is my accepted code customize sort

In second code

bool cmp(i64 a,i64 b){
 return a>=b
}
sort(lst[i].begin(),lst[i].end(),cmp)
This code got Runtime error.

My question is that if my customize funtion in 2nd code is

wrong then My verdict will be Wrong but why Runtime Error. Thanks in Advance.

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +23 Vote: I do not like it

I think it is because the compare function must return false for equal elements. You can go to this link (http://www.cplusplus.com/reference/algorithm/sort/)