nerd's blog

By nerd, 12 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

»
12 years ago, # |
  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()

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

And what is better map or set ?

  • »
    »
    12 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    And what is better coffee or tea?

    • »
      »
      »
      12 years ago, # ^ |
        Vote: I like it +13 Vote: I do not like it

      And what is better Mars or Snickers ?

      • »
        »
        »
        »
        12 years ago, # ^ |
          Vote: I like it -8 Vote: I do not like it

        And what is better boys or girls?

        • »
          »
          »
          »
          »
          12 years ago, # ^ |
            Vote: I like it +13 Vote: I do not like it

          And what is better hands or legs ?

          • »
            »
            »
            »
            »
            »
            12 years ago, # ^ |
              Vote: I like it -8 Vote: I do not like it

            And what is better Real or Barcelona?

            • »
              »
              »
              »
              »
              »
              »
              12 years ago, # ^ |
                Vote: I like it +10 Vote: I do not like it

              And what is better Pepsi or Cola ?

              • »
                »
                »
                »
                »
                »
                »
                »
                12 years ago, # ^ |
                  Vote: I like it -8 Vote: I do not like it

                And what is better Ferrari or Maserati? (Actually, I have both)

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  12 years ago, # ^ |
                  Rev. 2   Vote: I like it +13 Vote: I do not like it

                  Good for you! And what is better Alex_KPR or MikeMirzayanov ?

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  12 years ago, # ^ |
                    Vote: I like it +6 Vote: I do not like it

                  And what is better left_shift or right_shift?

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  12 years ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  And what is better читать чужие смс или знать где находится твоя вторая половинка?

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  12 years ago, # ^ |
                    Vote: I like it +6 Vote: I do not like it

                  Смотреть онлайн без регистрации!

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  12 years ago, # ^ |
                    Vote: I like it +6 Vote: I do not like it

                  So, now it is clear that sort() is better!

»
12 years ago, # |
  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.