void orderc_c ( SpiceInt lenvals,
const void * array,
SpiceInt ndim,
SpiceInt * iorder )
Determine the order of elements in an array of character strings.
None.
ARRAY, SORT
VARIABLE I/O DESCRIPTION
  
lenvals I String length.
array I Input array.
ndim I Dimension of array.
iorder O Order vector for array.
lenvals is the declared length of the strings in the input
string array, including null terminators. The input
array should be declared with dimension
[ndim][lenvals]
array is the input array.
ndim is the number of elements in the input array.
iorder is the order vector for the input array.
iorder[0] is the index of the smallest element
of array; iorder[1] is the index of the next
smallest; and so on. Strings are ordered according
to the ASCII collating sequence. Trailing white space
is ignored when comparing strings.
The elements of iorder range from zero to ndim1.
None.
1) If the input string pointer is null, the error
SPICE(NULLPOINTER) will be signaled.
2) If the input array string's length is less than 2, the error
SPICE(STRINGTOOSHORT) will be signaled.
3) If ndim < 1, this routine returns immediately. This case is not
considered an error.
None.
orderc_c finds the index of the smallest element of the input
array. This becomes the first element of the order vector.
The process is repeated for the rest of the elements.
The order vector returned by orderc_c may be used by any of
the reord* routines to sort sets of related arrays, as shown
in the example below.
In the following example, the order and reord routines are
used to sort four related arrays (containing the names,
masses, integer ID codes, and visual magnitudes for a group
of satellites). This is representative of the typical use of
these routines.
#include "SpiceUsr.h"
.
.
.
/.
Sort the object arrays by name.
./
orderc_c ( namlen, names, n, iorder );
reordc_c ( iorder, n, namlen, names );
reordd_c ( iorder, n, masses );
reordi_c ( iorder, n, codes );
reordd_c ( iorder, n, vmags );
1) String comparisons performed by this routine are Fortranstyle:
trailing blanks in the input array or key value are ignored.
This gives consistent behavior with CSPICE code generated by
the f2c translator, as well as with the Fortran SPICE Toolkit.
Note that this behavior is not identical to that of the ANSI
C library functions strcmp and strncmp.
None.
N.J. Bachman (JPL)
I.M. Underwood (JPL)
CSPICE Version 1.0.0, 18JUL2002 (NJB) (IMU)
order of a character array
