-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort_params.c
89 lines (75 loc) · 2.3 KB
/
sort_params.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*+
* United States Geological Survey
*
* PROJECT : Modular Modeling System (MMS)
* NAME : sort_params.c
* AUTHOR :
* DATE : Thu 15 Sep 1994
* FUNCTION : sort_params
* COMMENT : sorts the param array so that the key for each structure
* is in increasing alphabetical order
* REF :
* REVIEW :
* PR NRS :
*
* $Id: sort_params.c 3058 2007-01-25 22:25:59Z rsregan $
*
$Revision: 3058 $
$Log: sort_params.c,v $
Revision 1.5 1996/02/19 20:01:12 markstro
Now lints pretty clean
Revision 1.4 1994/09/30 14:55:20 markstro
Initial work on function prototypes.
* Revision 1.3 1994/09/19 15:51:17 markstro
* Fixed multiple dimension edit parameter window.
*
* Revision 1.2 1994/01/31 20:17:33 markstro
* Make sure that all source files have CVS log.
*
-*/
/**1************************ INCLUDE FILES ****************************/
#define SORT_PARAMS_C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "mms.h"
/**2************************* LOCAL MACROS ****************************/
/**3************************ LOCAL TYPEDEFS ***************************/
/**4***************** DECLARATION LOCAL FUNCTIONS *********************/
/**5*********************** LOCAL VARIABLES ***************************/
/**6**************** EXPORTED FUNCTION DEFINITIONS ********************/
/*--------------------------------------------------------------------*\
| FUNCTION : sort_params
| COMMENT :
| PARAMETERS :
| RETURN VALUE :
| RESTRICTIONS :
\*--------------------------------------------------------------------*/
void sort_params (void) {
PARAM **params;
PARAM *tmpparam;
int i, j;
params = Mparambase;
/*
** Make a array of the unsorted parameter order.
*/
if (!unsort_params) {
unsort_params = (PARAM **)malloc (Mnparams * sizeof (PARAM *));
for (i = 0; i < Mnparams; i++)
unsort_params[i] = params[i];
}
/*
** Sort the parameter data base
*/
for (i = Mnparams-2; i >= 0; i--) {
for (j = 0; j <= i; j++) {
if(strcmp(params[j]->key,params[j+1]->key) > 0) {
tmpparam = params[j];
params[j] = params[j+1];
params[j+1] = tmpparam;
}
}
}
}
/**7****************** LOCAL FUNCTION DEFINITIONS *********************/
/**8************************** TEST DRIVER ****************************/