Oh man....

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • I just ran across the following comment in our code:

      Source Code

      1. // Bubble sort. Nyah! Nyah!


      D'oh! Fortunately it was #ifdef'ed out... but still... it was live at some point, hehe.

      -Rez
    • RE: Oh man....

      What's wrong with good old bubble sort????
      It's great on already nearly sorted doubly linked lists....
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • RE: Oh man....

      Really? I was taught to tear out my own eyes rather then use bubble sort since every other sorting method is faster. I really thought it was just a learning tool rather than a viable sorting method for production code since it's O(n2). Why not use the STL sort() algorithm?

      Interestingly enough, that's pretty much how we used it. It's job was to sort a vector that was already in the correct order most of the time. We have a series of headshots at the top of our toolbar for each of the workers in Rat Race. It sorted that list based on loyalty, which had an average of about 10 - 15 elements. When you sort the list the first time, it generally stays in order except for one person here or there when loyalty changes.

      We replaced the bubble sort when we ripped out that whole system. I think it's done with messaging now (whenever loyalty changes, a message is sent to the kilroy manager telling it to reposition that headshot).

      Now I'm curious.... maybe I'll write a little test and profile the results.

      -Rez
    • Bubble sort is the only sort I can do well off the top of my head. I am guilty of implementing bubble sort when I think I'll revisit the code later. I do very much agree on it not being the best choice for a shipping retail version, though.

      If you're going to sort a linked list, then you might as well make sure that you insert the item in the right order instead of insert, then sort. That way, at least you get O(n) instead of O(n^2).