Dear all,
What is better in C++ sort()
or stable_sort()
?
Thanks
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Name |
---|
sort()
is faster, but it doesn't support stability as opposed tostable_sort()
And what is better map or set ?
And what is better coffee or tea?
And what is better Mars or Snickers ?
And what is better boys or girls?
And what is better hands or legs ?
And what is better Real or Barcelona?
And what is better Pepsi or Cola ?
And what is better Ferrari or Maserati? (Actually, I have both)
Good for you! And what is better Alex_KPR or MikeMirzayanov ?
And what is better left_shift or right_shift?
And what is better читать чужие смс или знать где находится твоя вторая половинка?
Смотреть онлайн без регистрации!
So, now it is clear that
sort()
is better!1) As it is already said, stable_sort is stable.
2) stable_sort is faster, if your campare operation is slow
I think stable_sort uses mergesort, and total number of compare operations used is less.