TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: All
from: Kurt Kuzba
date: 2003-09-01 05:10:48
subject: getopt()

From: kkuzba{at}centurytel.net
To: c_echo{at}yahoogroups.com

* Author: Jasen Betts
JB>  my only contribution to sorting algorithms was a way to
JB>  apply a radix sort (which is order N and thefore faster
JB>  than qsort etc on lkarge lists) to floating point data...
JB>  dunno if anyone reembers that.

    I remember that thread.  I even played around with the radix
 sort for a little bit and came up with this:

/*_|_|   RADXCHAR.C   PUBLIC DOMAIN   Kurt Kuzba  (6/16/1999)
_|_|_|   Perform a radix sort to order a list of words by their
_|_|_|   character value.
_|_|*/
#include 
#include 
typedef struct { void *list_item, *list_next; } Generic_linked_list;
void radix_sort_char(char**, int, int);
int main(void)
{
   char *Sortlist[10] = {
      "Apple", "Cherry", "Banana",
"Peach", "Pineapple",
      "Grape", "Avacado", "Guava",
"Orange", "Pear" };
   int pos;
   for(pos = 10; pos >= 0; pos--)
      radix_sort_char(Sortlist, 10, pos);
   for(pos = 0; pos < 10; pos++)
      puts(Sortlist[pos]);
   return 0;
}
void radix_sort_char(char **list, int elements, int position)
{
   int item, next = 256, pos;
   Generic_linked_list *Sort_bins, *walker;
   Sort_bins = calloc(256 + elements, sizeof(Generic_linked_list));
   if(!Sort_bins)
   {
      puts("calloc error!");
      exit(1);
   }
   for(item = 0; item < elements; item++)
   {
      pos = list[ item ][ position ];
      walker = Sort_bins + pos;
      if(walker->list_item)
      {
         while(walker->list_next)
            walker = walker->list_next;
         walker->list_next = Sort_bins + next++;
         walker = walker->list_next;
      }
      walker->list_item = list[item];
   }
   for(item = next = 0; item < 256; item++)
   {
      walker = Sort_bins + item;
      if(walker->list_item)
         do  {
            list[next++] = walker->list_item;
            walker = walker->list_next;
         } while(walker);
   }
   free(Sort_bins);
}
/*_|_| END _|_|*/

    That was a long, long time ago, according to my PD notice.
 Four years, in fact.

>  kkuzba{at}centurytel.net   http://home.centurytel.net/kkuzba
>  'Behold Eorl the Young!' said Aragorn. 'Thus he rode out
>  of the North to the Battle of the Field of Celebrant

--- SoupGate-Win32 v1.05
* Origin: kkuzba{at}centurytel.net (2:292/516.666)
SEEN-BY: 633/267 270
@PATH: 292/516 854 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.