Re: [BLACKBOX] Sorting a Dialog.List

From: [at]} <Robert>
Date: Fri, 7 Sep 2012 20:00:38 +0100


Steve

I think you are misleading us - this is not a 'newbie' question!

My guess that your list was short was pretty comprehensively wrong!

Get / Set item seems to scan the list to find the item, so that makes a Bubble
sort n^3. That shoud give time for the icecap to refreeze.

Do you expect the user to select items from your 33000 element list using a mouse and a DropDown GUI?
Or are you just using the Dialog.List as a convenient internal data structure for your algorithm?

If the latter you could try Module LibCycles (same URL as before). It implements a doubly linked list (which
I think is better for this kind of task) and a Merge sort.

The Merge sort is n * Ln n, both on average and worst case. For that reason I prefer it to QuickSort, which has bad worst case performance.


Regards

Robert



On 07/09/2012 16:34, Stephen R. Troy wrote:


        
        Thanks, Robert, but this method, with GetItem and SetItem, involves reading the complete entries out of the list and then writing them back in at a different position, which is very slow. I was hoping for a method that simply swapped the StrList.items, which are apparently pointers to the list entries, leaving the entries themselves in place, which would obviously be much faster. Unfortunately these are not accessible from outside the Dialog module. My list is currently up to about 33,000 entries. So an external bubble sort works, acceptably fast on a small test list, but with the full 33,000 and the bubble sort's n^2 time, the polar icecap is melting faster. I guess next I'll try to implement a QuickSort. Thanks anyway,
        Steve Troy in Maryland USA
        

                -------- Original Message --------
                Subject: Re: [BLACKBOX] Sorting a Dialog.List
                From: Robert <robert.campbell_{([at]})nowhere.xy
                Date: Thu, September 06, 2012 6:03 pm
                To: BLACKBOX{([at]})nowhere.xy
                
                
                Stephen
                
                The following routine (from LibMisc on CPC http://www.zinnamturm.eu/downloadsIN.htm#Lib) is a 'clunky' way of solving a different
                problem, but it might give you some ideas.
                
                The Docu & Mod extracts are:
                
                
                
                
                
                
                
                
                I would guess that your lists are fairly short, so a simple Bubble sort would be fine?
                
                
                Cheers
                
                Robert.
                
                
                
                On 06/09/2012 21:40, Stephen R. Troy wrote:
                

                        
                        Dear List, another newbie question: is there a non-clunky way to sort the items in a Dialog.List object? I'm nervous about going inside the Dialog module, and apparently the individual "items" in the List are not accessible from outside the Dialog module. Hint, hint: it sure would be swell if a new release included such a Sort method. Obviously I could do my sorting before entering the items into the list, but for various reasons this would be clumsy. Any suggestions appreciated.
                        Steve Troy in Maryland USA

                        No virus found in this message.
                        Checked by AVG - www.avg.com
                        Version: 2012.0.2197 / Virus Database: 2437/5252 - Release Date: 09/06/12
                        ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy


                ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy

        No virus found in this message.
        Checked by AVG - www.avg.com
        Version: 2012.0.2197 / Virus Database: 2437/5254 - Release Date: 09/07/12

        ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy


---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
Received on Fri Sep 07 2012 - 21:00:38 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:29:56 UTC