Alphabetizer FUNCTION

 BBS: Inland Empire Archive
Date: 12-10-92 (02:52)             Number: 360
From: JOHN SNEERINGER              Refer#: NONE
  To: SHANE HEADER                  Recvd: NO  
Subj: Alphabetizer FUNCTION          Conf: (2) Quik_Bas
* Originally addressed to All, Shane Header said:
SH->        Does anyone have a FUNCTION that that will
SH->alphabatize a complete
SH->string array? I have tried unsucessfuly. I'm sure I could do
SH->it, but I
SH->thought I would check with you guys to see if you had one
SH->lying around.

DEFINT A-Z

' ==============================================================
' The Fastest QuickBasic Sort Routine Alive. 516% faster than
' any living bubble array. THIS ONE DOES STRINGS, NOT NUMERICS.
' ==============================================================

DECLARE FUNCTION RandInt% (Lower, Upper)
DECLARE SUB QuickSort (Low, High)
DIM SHARED SortArray$(11)

CLS

SortArray$(1) = "6"
SortArray$(2) = "3"
SortArray$(3) = "5"
SortArray$(4) = "6"
SortArray$(5) = "8"
SortArray$(6) = "9"
SortArray$(7) = "5"
SortArray$(8) = "4"
SortArray$(9) = "3"
SortArray$(10) = "2"
SortArray$(11) = "1"
Low = 1
High = 11


CALL QuickSort(Low, High)

FOR a = Low TO High
PRINT SortArray$(a)
NEXT

SUB QuickSort (Low, High)

   IF Low < High THEN

      IF High - Low = 1 THEN
         IF SortArray$(Low) > SortArray$(High) THEN
            SWAP SortArray$(Low), SortArray$(High)
         END IF
      ELSE

         RandIndex = RandInt%(Low, High)
         SWAP SortArray$(High), SortArray$(RandIndex)
         Partition$ = SortArray$(High)
         DO

            I = Low: J = High
            DO WHILE (I < J) AND (SortArray$(I) <= Partition$)
               I = I + 1
--- D'Bridge 1.30/071082
 * Origin: RadioLink! Columbus, OH (614)766-2162 HST/DS (1:226/140)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET