[comp.sys.amiga] mg2a patch for sorted buffer menus: source for tqsort

jw@obelisk.sics.se (Johan Widen) (06/24/88)

A previously posted patch for mg release 2a refers to thfunction
	tqsort()

This function is provided by the Lattice library but not by the Manx library.
Enclosed is a version that should work with Manx. The original source comes
from the Amiga Hack program (Software Distillery).

tqsort(v, n)
register char **v;
int n;
   {
   register char *temp;
   register int gap, j, i;

   for (gap=n/2; gap > 0 ; gap /= 2)
      for (i=gap; i<n; i++)
         for (j = i-gap; j >= 0; j -= gap)
	    if (strcmp(v[j], v[j + gap]) > 0)
               {
               /* exchange them */
	       temp = v[j];
	       v[j] = v[j + gap];
	       v[j + gap] = temp;
               }
   }

--
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30
Internet: jw@sics.se or {mcvax,munnari,ukc,unido}!enea!sics.se!jw