Fastest Sort Routine

Discussion in 'Game Development General Discussion' started by Piglet, Dec 6, 2008.

  1. Piglet

    Piglet Spirited Member

    Joined:
    May 28, 2008
    Messages:
    175
    Likes Received:
    0
    Now, think back to 1986. That is when I submitted a big group of sort routines as my practical for my O-level. It was for the C64 and was used in a sprite-multiplexer.

    1-Simple bubble sort.
    2-Bubble with early exit.
    3-Bubble with reducing sort size (after 1 itteration, 1 number is sorted).
    4-Quicksort
    5-binary sort

    Now, one that people may not know of, as invented by Sensible Software:

    6-Bucket sort

    The last one is the interesting one. The thing is, a multiplex sort doesn't have to be perfect, just quite close. These guys divided the Y-position by 2 and then placed the number in the bottom 1/2 of the stack. If there was already a number there, they checked the next position until they found a free space. It was very fast and I never got it to fall over.

    Anyone else come across unusual or even unique sort routines?
     
  2. Johnny

    Johnny Gran Turismo Freak and Site Supporter 2013,2015

    Joined:
    Mar 14, 2004
    Messages:
    6,230
    Likes Received:
    397
    Radix Sort maybe? It's fast and stable.
     
  3. smf

    smf mamedev

    Joined:
    Apr 14, 2005
    Messages:
    1,255
    Likes Received:
    88
    my favourite has to be mergesort for linked lists

    http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html

    I've always meant to code a multiplexor with it. I used it after an insertion sort ground to it's knees. The other side to that is a binary search of the linked list. I've only used it with string keys, whether it has much of an advantage with chars/shorts/longs I don't know.
     
  4. Quzar

    Quzar Spirited Member

    Joined:
    Dec 10, 2006
    Messages:
    167
    Likes Received:
    1
    Sensible software wasn't founded till 1986... and bucket sort was invented in 1978 by Wlodzimierz Dobosiewicz (according to my algorithms class).

    I've always thought randomized quicksort was nice when a quick randomization is availible. What's fun though is to try and find some odd opcode that does some funky swizzling to allow you to do... whatever better.
     
  5. drx

    drx BLAST PROCESSING. SITE SUPPORTER 2015

    Joined:
    Jun 16, 2006
    Messages:
    509
    Likes Received:
    275
    Funny, I coded a linked list merge sort just yesterday. It is nice, indeed.
     
  6. Piglet

    Piglet Spirited Member

    Joined:
    May 28, 2008
    Messages:
    175
    Likes Received:
    0
    True bucket-sort yes, but this faster, approximate sort was Sensible.
     
sonicdude10
Draft saved Draft deleted
Insert every image as a...
  1.  0%

Share This Page