Sorting

 BBS: Inland Empire Archive
Date: 03-25-93 (14:29)             Number: 338
From: DIK COATES                   Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: Sorting                        Conf: (2) Quik_Bas
- Area: Quik_Bas -------------------------------------------------------------
  Msg#: 290                                          Date: 03-23-93  18:43
  From: Leonard Erwine                               Read: Yes    Replied: No
    To: Daniel Stasinski                             Mark:

  Subj: Re: did i make it up?
___
Yeah, those recursive sorting algorythms can eat up alot of stack space and also dynamic memory space. I never did like shell sorting algorythms anyway. This shell sort is non-recursive... '******************************************************* SUBPROGRAM ShellSort ' ' Procedure uses the Shell-Metzger algorithm for sorting an array of string ' variables. Adapted from an article by Donald Shell and disassembled IBM ' 360 machine language. This sorting algorithm is extremely efficient for ' sorting small and medium sized arrays. ' ' PARAMETERS: col0% = number of elements in the string array array$() ' array$() = string variable array to be sorted. ' RETURNS: array$() = sorted string variable array ' ' Released to Public Domain, 1993, by R.A. Coates ' SUB ShellSort (col0%, array$()) col1% = col0% WHILE col1% col1% = col1% \ 2 col2% = col0% - col1% FOR count% = 1 TO col2% col3% = count% sort1: col4% = col3% + col1% IF array$(col3%) <= array$(col4%) THEN GOTO sort2 ELSE SWAP array$(col3%), array$(col4%) col3% = col3% - col1% END IF IF col3% > 0 THEN GOTO sort1 END IF sort2: NEXT count% WEND END SUB It was done many years back... and if you ignore the goto's (actually, they're the fastest way to get somewhere!) you'll find it really quite fast... Regards Dik, Oshawa, Canada ... "Hey! Who took the cork off my lunch??!" ___ Blue Wave/QWK v2.10 --- Maximus 2.01wb * Origin: Durham Systems (ONLINE!) (1:229/110)
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