No announcement yet.

32 bit high speed sort in PowerBASIC complete with a usable source.

  • Filter
  • Time
  • Show
Clear All
new posts

  • 32 bit high speed sort in PowerBASIC complete with a usable source.

    I have posted this in the MASM forum to avoid cluttering the PB forum. The sort can be directly used in a PowerBASIC app by simply including the file "fastsort.bas". While its internals are very complicated, it is simple use and genuinely fast. It only performs a simple sort in either direction and requires that each line is CRLF terminated. Nother else should be used.
    hutch at movsd dot com
    The MASM Forum

  • #2
    I wrote a little app using the native PB ARRAY SORT that does the same steps as your fastsort. It was only about 10 times slower........... Wow.

    So, I am going to try to incorporate this into an existing app I have. I am wearing rubber gloves, and have wrapped myself in multiple layers of bubble-wrap. I hope that helps as I delve into this project.

    BTW... what kind of snakes?
    ... .... . ... . . ... ... .... . .. ... .... .. ... .... .. .... ..

    n6jah @


    • #3
      Glad you could find a use for it Jim. Its the usual trade off, flexibility for speed. The PB sort is very flexible, can be set up to a variety of different things where this hybrid sort will only do simple sorts in either direction. It is the fastest I have seen though but incredibly messy to code. It started life as a C algo converted to asm in its unoptimised form, manually optimised which by the way was no faster than the C version and with the advent of new capacity in the current versions of PB, converted to PB format.

      Snakes ?

      I think you have rattlesnakes over your way, you don't want any of ours, they are even nastier but I forgot to mention the electric eels in the moat to make the crocodiles behave themselves.
      Last edited by Steve Hutchesson; 22 Sep 2017, 05:29 PM.
      hutch at movsd dot com
      The MASM Forum


      • #4
        >the electric eels in the moat...
        they've got them too....if you go south far enough and watching river monsters I can easily believe they'd sort the crocs out

        Is it this one?
        std::sort is implemented as a intro-sort (introspective sort), which is basically a Quicksort that keeps track of its recursion depth, and will switch to a Heapsort (usually slower but guaranteed O(n log n) complexity) if the Quicksort is using too deep of recursion.

        >which by the way was no faster than the C version
        That made me smile but it sounds like very good c coding.
        Last edited by Dean Gwilliam; Today, 03:02 PM.


        • #5
          It is close to a perfect design that combines a radix, quick and insertion sort. The insertion sort handles the deep recursion basically as an end trimmer where the quick sort overhead is too high for small numbers that you get at the furthest reach of recursion. I converted it to unoptimised assembler mnemonics, used it as a test piece for a tool I was designing where I manually optimised it but could not get it any faster than the C version. Having it in asm mnemonic form allowed me to post it both to MASM and later to PB.
          hutch at movsd dot com
          The MASM Forum


          • #6
            Good job.
            Do you remember the email I sent you in June?
            Any tips to get exactly the same code for a double-precision arrays?



            • #7
              That's very interesting and certainly sounds like a step up from the intro-sort algorithm.
              Thank you very much for allowing us all to benefit from it.
              Last edited by Dean Gwilliam; Today, 03:03 PM.