| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Sorting program |
Here's a sorting program I had to write when I needed to sort rows of data
by information a few columns from the left edge.
You can stick it in OZPD if you like. The sort routine is just a simple
one - if anyone wants to improve on it be my guest!
/*****************************************************************************/
/*
*/ /* This program Written by Joshua Marshall
*/ /*
*/
/*****************************************************************************/
/*****************************************************************************/
/*
*/ /*
*/ /* Sort - sort a text file on a certain column and datatype
*/ /*
*/ /*
*/ /* This program is released to the public domain.
*/ /*
*/ /* Written December 1996.
*/ /*
*/
/*****************************************************************************/
/*****************************************************************************/
/* Local includes
*/
/*****************************************************************************/
#include
#include
#include
#include
/*****************************************************************************/
/* Local defines
*/
/*****************************************************************************/
#define ALPHA_TYPE 1
#define NUMBER_TYPE 2
#define UP_TYPE 0
#define DOWN_TYPE 1
/*****************************************************************************/
/* Local structures
*/
/*****************************************************************************/
typedef struct LINE
{
char *text;
struct LINE *nextline;
} line;
/*****************************************************************************/
/* Global variables
*/
/*****************************************************************************/
char *filein=NULL;
char *fileout=NULL;
int field=0;
int datatype=0;
int direction=0;
line firstline;
int numlines=0;
/*****************************************************************************/
/* Local variables
*/
/*****************************************************************************/
/*****************************************************************************/
/* Local functions
*/
/*****************************************************************************/
static int compare(char *s1, char *s2)
{
char *tmp1;
char *tmp2;
char *tok1;
char *tok2;
int i;
if (field>0)
{
tmp1=(char *)(malloc(strlen(s1)+1));
tmp2=(char *)(malloc(strlen(s2)+1));
strcpy(tmp1,s1);
strcpy(tmp2,s2);
tok1=strtok(tmp1," ");
for (i=1;i * Origin: Borderline Technologies (3:640/201.14{at}fidonet)SEEN-BY: 633/267 270 @PATH: 640/201 201 820 711/409 808 50/99 635/728 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™.