Index of Functions: A B C D E F G H I J K L M N O P Q R S T U V W X
Index Page shellc_c

Table of contents

Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries

#### Procedure

       shellc_c ( Shell sort a character array )

       void shellc_c ( SpiceInt     ndim,
                       SpiceInt     arrlen,
                       void       * array   )

#### Abstract

       Sort an array of character strings according to the ASCII
       collating sequence using the Shell Sort algorithm.

#### Required_Reading

       None.

#### Keywords

       ARRAY
       SORT

#### Brief_I/O

       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       ndim       I   Dimension of the array.
       arrlen     I   String length.
       array     I-O  The array.

#### Detailed_Input

       ndim        is the number of elements in the array to be sorted.

       arrlen      is the declared length of the strings in the input
                   string array, including null terminators. The input
                   array should be declared with dimension

                      [ndim][arrlen]

       array       on input, is the array to be sorted.

#### Detailed_Output

       array       on output, contains the same elements, sorted
                   according to the ASCII collating sequence.
                   The actual sorting is done in place in array.

#### Parameters

       None.

#### Exceptions

       1)  If ndim < 2, this routine does not modify the array.

       2)  If the `array' input array pointer is null, the error
           SPICE(NULLPOINTER) is signaled.

       3)  If the `array' input array strings have length less than two
           characters, the error SPICE(STRINGTOOSHORT) is signaled.

#### Files

       None.

#### Particulars

       The Shell Sort Algorithm is well known.

#### Examples

       Let array contain the following elements:

          "FEYNMAN"
          "NEWTON"
          "EINSTEIN"
          "GALILEO"
          "EUCLID"
          "Galileo"

       Then after a call to shellc_c, the array would be ordered as
       follows:

          "EINSTEIN"
          "EUCLID"
          "FEYNMAN"
          "GALILEO"
          "Galileo"
          "NEWTON"

#### Restrictions

       1)  The input array is assumed to be sorted in increasing order. If
           this condition is not met, the results of bsrchc_c are unpredictable.

       2)  String comparisons performed by this routine are Fortran-style:
           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.

#### Literature_References

       None.

#### Author_and_Institution

       N.J. Bachman        (JPL)
       J. Diaz del Rio     (ODC Space)
       I.M. Underwood      (JPL)

#### Version

       -CSPICE Version 1.1.0, 05-AUG-2021 (JDR)

           Changed the input argument name "lenvals" to "arrlen" for consistency
           with other routines.

           Edited the header to comply with NAIF standard.

       -CSPICE Version 1.0.0, 18-JUL-2002 (NJB) (IMU)

#### Index_Entries

       shell sort a character array

#### Link to routine shellc_c source file shellc_c.c

    Fri Dec 31 18:41:12 2021