USG_PG3/usr/source/lexgen2/ssort.c

Compare this file to the similar file:
Show the results in this format:

sort(nitem, compar, swap)
	int (*compar)(), (*swap)();
{ /* shell sort - copied from kernighan and plauger */
	int igap, imax, iplusg, iex, i;
	for (igap=nitem/2; igap >0; igap =/ 2)
	   {
	   imax = nitem-igap;
	   iex = 1;
	   while (iex)
		{
		iex = 0;
		for(i=0; i<imax; i++)
			{
			iplusg = i+igap;
			if (!((*compar)(i,iplusg)))
				{
				(*swap)(i,iplusg);
				iex = 1;
				}
			}
		}
	}
}