Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!ucbvax!VTVM1.BITNET!GRANGERG From: GRANGERG@VTVM1.BITNET (Greg Granger) Newsgroups: comp.lang.modula2 Subject: Re: Sorts Message-ID: Date: 12 Sep 89 15:38:35 GMT References: Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Modula2 List Organization: The Internet Lines: 38 AB>From: Alex Bewley AB>Bubble sort is a little bit too slow for my application. I need to AB>... AB>pointers become mixed up and you end up trying to sort the interrupt AB>... AB>which I don't want to do. Well, I was having the same problem a few months back. I was using TopSpeed Modula-2 to read a directory (queue the filenames of a dir.) and wanted to sort the results. TopSpeed provides a very useful QuickSort and HeapSort with their 'standard' libraries, but these routines quite reasonably expected a indexed list. (Note that the TopSpeed canned sorts require as arguments the list size, a Less than procedure and a Swap procedure, therefore the use of ARRAYs is not mandated, this is not true with all such canned sorts) In any case, what I did was write a module that allowed GETs, PUTs and SWAPs on a heap based indexed list. This allows dynamic array handling, which solved my problem. I have been reworking this module lately to include, unlike types (not `true' arrays), dropping elements, deinit'ing (kill the array and recovering all heap space used), etc... I would be happy to share my source code with you with the following understanding: (A) this is a module being actively tested (deinit'ing is at this time not functional) (B) it's written in TopSpeed Modula-2 with absolutely no attention given to keeping with the Wirth defined standard (ie if TS gave me a special non-standard function that made things easier I used it). (C) Please don't pass the source code around, while I believe that it will help you, it is not finished to the point that I would like to have it floating around with my name on it. ----- To interested other readers. If other are interested in this code, let me know and I will consider releasing it to the list when I have finished testing and debugging. Greg (GRANGERG @ VTVM1)