Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Programming chalenge: Bogosort

Programming chalenge: Bogosort

Scheduled Pinned Locked Moved The Lounge
c++algorithmscsharplounge
24 Posts 15 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nemanja Trifunovic
    wrote on last edited by
    #1

    Just learned about the best sorting algorithm ever: Bogosort[^] Here is my implementation in C++ (note use of C++0x is_sorted algorithm):

    template <class RandomAccessIterator, class Compare>
    void bogo_sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
    {
    while (!is_sorted(first, last, comp))
    random_shuffle(first, last);
    }

    utf8-cpp

    J G B N B 7 Replies Last reply
    0
    • N Nemanja Trifunovic

      Just learned about the best sorting algorithm ever: Bogosort[^] Here is my implementation in C++ (note use of C++0x is_sorted algorithm):

      template <class RandomAccessIterator, class Compare>
      void bogo_sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
      {
      while (!is_sorted(first, last, comp))
      random_shuffle(first, last);
      }

      utf8-cpp

      J Offline
      J Offline
      Jim Crafton
      wrote on last edited by
      #2

      Dude, haven't you heard? The best sorting is probably found in Qt!!!

      ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

      P N M 3 Replies Last reply
      0
      • N Nemanja Trifunovic

        Just learned about the best sorting algorithm ever: Bogosort[^] Here is my implementation in C++ (note use of C++0x is_sorted algorithm):

        template <class RandomAccessIterator, class Compare>
        void bogo_sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
        {
        while (!is_sorted(first, last, comp))
        random_shuffle(first, last);
        }

        utf8-cpp

        J Offline
        J Offline
        Jim Crafton
        wrote on last edited by
        #3

        Also I note that the wiki page does not list the Baconsort method. What's wrong with these freaks? Don't they know anything about computer science? //edit (they do now!!) :)

        ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

        modified on Friday, January 28, 2011 4:53 PM

        T 1 Reply Last reply
        0
        • J Jim Crafton

          Dude, haven't you heard? The best sorting is probably found in Qt!!!

          ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          Why are you trolling, fule. U knw that Qt is only pl imitates of VCF bcoz I say so and am GOING TO SHOUT VERY LOUDLY to hide the paucity of my argument.

          I'm not a stalker, I just know things. Oh by the way, you're out of milk.

          Forgive your enemies - it messes with their heads

          My blog | My articles | MoXAML PowerToys | Onyx

          J 1 Reply Last reply
          0
          • N Nemanja Trifunovic

            Just learned about the best sorting algorithm ever: Bogosort[^] Here is my implementation in C++ (note use of C++0x is_sorted algorithm):

            template <class RandomAccessIterator, class Compare>
            void bogo_sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
            {
            while (!is_sorted(first, last, comp))
            random_shuffle(first, last);
            }

            utf8-cpp

            J Offline
            J Offline
            Jim Crafton
            wrote on last edited by
            #5

            Now the entry makes a little more sense, pfft! kthnksby!

            ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

            S 1 Reply Last reply
            0
            • P Pete OHanlon

              Why are you trolling, fule. U knw that Qt is only pl imitates of VCF bcoz I say so and am GOING TO SHOUT VERY LOUDLY to hide the paucity of my argument.

              I'm not a stalker, I just know things. Oh by the way, you're out of milk.

              Forgive your enemies - it messes with their heads

              My blog | My articles | MoXAML PowerToys | Onyx

              J Offline
              J Offline
              Jim Crafton
              wrote on last edited by
              #6

              I was with you till "paucity" - that's way too complicated of a word!!! :)

              ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

              1 Reply Last reply
              0
              • J Jim Crafton

                Also I note that the wiki page does not list the Baconsort method. What's wrong with these freaks? Don't they know anything about computer science? //edit (they do now!!) :)

                ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                modified on Friday, January 28, 2011 4:53 PM

                T Offline
                T Offline
                TheGreatAndPowerfulOz
                wrote on last edited by
                #7

                you must have added it!

                "If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams

                J 1 Reply Last reply
                0
                • T TheGreatAndPowerfulOz

                  you must have added it!

                  "If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams

                  J Offline
                  J Offline
                  Jim Crafton
                  wrote on last edited by
                  #8

                  Me!?? Are you out of your mind?! That's absurd.

                  ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                  A 1 Reply Last reply
                  0
                  • J Jim Crafton

                    Now the entry makes a little more sense, pfft! kthnksby!

                    ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                    S Offline
                    S Offline
                    Steve Maier
                    wrote on last edited by
                    #9

                    Thanks for adding bacon to this thread too. :)

                    Steve Maier

                    J 1 Reply Last reply
                    0
                    • S Steve Maier

                      Thanks for adding bacon to this thread too. :)

                      Steve Maier

                      J Offline
                      J Offline
                      Jim Crafton
                      wrote on last edited by
                      #10

                      Sorry got a little carried away, you know a sausage in the hand is worth some bacon in the pan (or something like that).

                      ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                      1 Reply Last reply
                      0
                      • J Jim Crafton

                        Me!?? Are you out of your mind?! That's absurd.

                        ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                        A Offline
                        A Offline
                        Andy Brummer
                        wrote on last edited by
                        #11

                        Fiend! You accuse me of writing farcebook games, and you go around brazenly wikiediting. Shame shame.

                        Curvature of the Mind

                        J 1 Reply Last reply
                        0
                        • A Andy Brummer

                          Fiend! You accuse me of writing farcebook games, and you go around brazenly wikiediting. Shame shame.

                          Curvature of the Mind

                          J Offline
                          J Offline
                          Jim Crafton
                          wrote on last edited by
                          #12

                          Speak not such foul language Lord Farcebook! Calm your self and realize only thusly: the spoon which you think you doth perceive, cast not it's silvry glint upon thine mind's eye! Think well upon this my friend, and perhaps you may yet take back your rough and uncouth words.

                          ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                          H 1 Reply Last reply
                          0
                          • N Nemanja Trifunovic

                            Just learned about the best sorting algorithm ever: Bogosort[^] Here is my implementation in C++ (note use of C++0x is_sorted algorithm):

                            template <class RandomAccessIterator, class Compare>
                            void bogo_sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
                            {
                            while (!is_sorted(first, last, comp))
                            random_shuffle(first, last);
                            }

                            utf8-cpp

                            G Offline
                            G Offline
                            Gary R Wheeler
                            wrote on last edited by
                            #13

                            I prefer this[^] sorting algorithm myself.

                            Software Zen: delete this;
                            Fold With Us![^]

                            H 1 Reply Last reply
                            0
                            • J Jim Crafton

                              Speak not such foul language Lord Farcebook! Calm your self and realize only thusly: the spoon which you think you doth perceive, cast not it's silvry glint upon thine mind's eye! Think well upon this my friend, and perhaps you may yet take back your rough and uncouth words.

                              ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                              H Offline
                              H Offline
                              Henry Minute
                              wrote on last edited by
                              #14

                              Is this a spoon I see before me?

                              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.

                              D 1 Reply Last reply
                              0
                              • G Gary R Wheeler

                                I prefer this[^] sorting algorithm myself.

                                Software Zen: delete this;
                                Fold With Us![^]

                                H Offline
                                H Offline
                                Henry Minute
                                wrote on last edited by
                                #15

                                Why, I outta...........!

                                Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.

                                G 1 Reply Last reply
                                0
                                • J Jim Crafton

                                  Dude, haven't you heard? The best sorting is probably found in Qt!!!

                                  ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                                  N Offline
                                  N Offline
                                  Nemanja Trifunovic
                                  wrote on last edited by
                                  #16

                                  Jim Crafton wrote:

                                  The best sorting is probably found in Qt!!!

                                  :-D And I bet it is twice as efficient as bogosort.

                                  utf8-cpp

                                  1 Reply Last reply
                                  0
                                  • H Henry Minute

                                    Why, I outta...........!

                                    Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.

                                    G Offline
                                    G Offline
                                    Gary R Wheeler
                                    wrote on last edited by
                                    #17

                                    Woo-woo-woo!

                                    Software Zen: delete this;
                                    Fold With Us![^]

                                    1 Reply Last reply
                                    0
                                    • N Nemanja Trifunovic

                                      Just learned about the best sorting algorithm ever: Bogosort[^] Here is my implementation in C++ (note use of C++0x is_sorted algorithm):

                                      template <class RandomAccessIterator, class Compare>
                                      void bogo_sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
                                      {
                                      while (!is_sorted(first, last, comp))
                                      random_shuffle(first, last);
                                      }

                                      utf8-cpp

                                      B Offline
                                      B Offline
                                      Bassam Abdul Baki
                                      wrote on last edited by
                                      #18

                                      Most guys would tell you the QuickieSort is the fastest.

                                      1 Reply Last reply
                                      0
                                      • N Nemanja Trifunovic

                                        Just learned about the best sorting algorithm ever: Bogosort[^] Here is my implementation in C++ (note use of C++0x is_sorted algorithm):

                                        template <class RandomAccessIterator, class Compare>
                                        void bogo_sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
                                        {
                                        while (!is_sorted(first, last, comp))
                                        random_shuffle(first, last);
                                        }

                                        utf8-cpp

                                        N Offline
                                        N Offline
                                        NetDave
                                        wrote on last edited by
                                        #19

                                        I'd love to see this sort algorithm visually[^]

                                        QRZ? de WAØTTN

                                        D P 2 Replies Last reply
                                        0
                                        • J Jim Crafton

                                          Dude, haven't you heard? The best sorting is probably found in Qt!!!

                                          ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                                          M Offline
                                          M Offline
                                          Mladen Jankovic
                                          wrote on last edited by
                                          #20

                                          :-D

                                          [Genetic Algorithm Library] [Wowd]

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups