nerd's blog

By nerd, 14 years ago, In Russian

Dear all,

What is better in C++ sort() or stable_sort()?

Thanks

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

»
14 years ago, hide # |
 
Vote: I like it +25 Vote: I do not like it

sort() is faster, but it doesn't support stability as opposed to stable_sort()

»
14 years ago, hide # |
 
Vote: I like it +24 Vote: I do not like it

And what is better map or set ?

»
14 years ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

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.