=========================================================================== BBS: The Abacus * HST/DS * Potterville, MI Date: 03-08-93 (13:26) Number: 149 From: DIK COATES Refer#: NONE To: BRYAN NYLIN Recvd: NO Subj: Looking for quicksort Conf: (35) Quick Basi --------------------------------------------------------------------------- >>>> QUOTING Bryan Nylin to All <<<< BN> I am looking for a simple quicksort function for QuickBASIC 4.5 that You can try the following... '***************************************************** SUBPROGRAM Sortshell ' ' Procedure uses the Shell-Metzger algorithm for sorting an array of string ' variables. Adapted from an article by Donald Shell and modified from IBM ' 360 ASM language listing. This sorting algorithm is extremely efficient ' for sorting small and medium sized arrays of random values. ' ' PARAMETERS: col0% = number of elements in the array array%() ' array%() = integer variable array to be sorted. ' RETURNS: array%() = sorted integer variable array ' ' LAST REV: 88-05-25;93/3 Entered into Public Domain, R.A. Coates, 93/03/06 ' SUB Sortshell (col0%, array%()) col1% = col0% WHILE col1% <> 0 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 The use of GOTO's are simple, clear, and faster than not using them! Modify as you see fit... Was originally a string array sort, but modified it for an other posting... Regards Dik, Oshawa, Canada ... ///\oo/\\\ There are no more bugs,///\oo/\\\ ///\oo/\\\ ___ Blue Wave/QWK v2.10 --- Maximus 2.01wb * Origin: Durham Systems (ONLINE!) (1:229/110) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/2 159/100 125 430 950 203/23 209/209 280/1 SEEN-BY: 390/1 396/1 15 397/2 2230/100 3603/20