[futurebasic] Re: [FB] Compact QuickSort

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2001 : Group Archive : Group : All Groups

From: Ken Shmidheiser <k.shmidheiser@...>
Date: Thu, 15 Nov 2001 11:18:23 -0500
tedd wrote:

>  >Here is a compact and versatile QuickSort function that can be used
>  >to sort string or numerical arrays. It uses a boolean switch to
>  >easily configure the array to be sorted in ascending or descending
>  >order.
>  >
>  >My next order of business is to try to utilize Jay's techniques with it.
>  >
>  >All comments welcome.
>  >
>  >Ken
>
>Ken:
>
>Two comments:
>
>1. On my machine your program reported 80 ticks.
>
>2. You have to add something to stop the program to see what's
>happening, such as INPUT">";a$ at the end of it.

tedd,

I'm a little dense here. What do you mean in comment 2?

I know when the function executes, it grabs the machine. Do you mean 
adding a timing event to allow an interrupt? Of would a DO : 
HANDLEEVENTS: UNTIL 0 : END take care of it? Can you take my code and 
give me a little example?

You, Jay and Robert P. are so far ahead of me when it comes to 
sorting that I beg mercy. I'm looking for something simple that I can 
understand and use. This started out in VB, but after a severe 
translation using all the FB^3 shorthand I'm aware of, it now bears 
no resemblance to the original. When I first saw it, I was struck by 
how compact the code is, but at the same time versatile. (The VB code 
allowed the array to be dimmed as a variant-- there is no counterpart 
to variant in FB^3-- which allowed the function to automatically sort 
whatever kind of variable was thrown at it.)

I have already used this code with a binary array search function and 
it seems to work very well. However, my search function only returns 
the last item of a given element in an array. For instance, if I have 
a 30-element string array with the 6th and 29th elements being the 
string "tedd", it will only return the 29th element. I sure would 
like to find a search function that finds the location of all 
identical elements.

On my G3 350 I consistently get between 110-120 ticks. I'm assuming 
you're using a G4. In your experience, how does this rate speedwise?

Thanks for the comments.

Ken