Sorts sequences within a string

        [<lDescending>]) --> cString

     Note:  This version of Clipper Tools contains an optional
     parameter that previous versions did not include.


     <cString>  [@]  Designates the character string that is sorted.

     <nElementlength>  Designates the length of the sorting element.  The
     default value is for 1 character.

     <nComparisonlength>  Designates the number of characters that a
     sorting element takes into account in a comparison.  The default value
     is <nElementlength> characters.

     <nIgnore>  Designates the number of characters at the beginning of
     the <cString> that should not be taken into account in the sorting.

     <nElementPosition>  Designates an offset.  This parameter designates
     from what position within the sorting element the comparison is made.
     The default value is the first character (0).

     <nSortlength>  Designates the length of the sort area relative to
     the <nIgnore> offset.

     <lDescending>  Designates whether the function sorts in ascending or
     descending order.  If this parameter is not specified, or is specified
     as .F., then the function sorts in ascending order.  When specified as
     .T., the function sorts in descending order.  The default value is .F..


     The sorted <cString> is returned.


     CHARSORT() allows you to sort the characters in a string in many
     different ways.  Everything from the length of the sorting elements to
     the sort sequences is taken into account.


     .  Invalid parameters return a null string.

     .  The function uses a fast sort algorithm.

     .  The return value of this function can be suppressed by
        implementing CSETREF() to save space in working memory.


     .  Sort characters in a string according to their ASCII code:

        ? CHARSORT("qwert")                           // "eqrtw"

     .  Sort 2-byte length elements:

        ? CHARSORT("qwert", 2)                        // "erqwt"

     .  Sort 2-byte length elements, but only use the first character
        for the comparison:

        ? CHARSORT("bla4a3a2a1", 2, 1)                // "a2a1a3a4b1"

     .  Sort individual characters, excluding the first three:

        ? CHARSORT("XXXqwert", 1, 1, 3)               // "XXXeqrtw"

     .  Sort paired sequences for the entire string, where only the
        second character within each sequence is used:

        ? CHARSORT("bla4a3a2a1", 2, 1, 0, 1)          // "a1b1a2a3a4"

     .  Sort only the first four characters within a string:

        ? CHARSORT("384172852", 1, 1, 0, 0, 4)        // "134872852"

     .  Sort in descending order:

        ? CHARSORT("qwert", .T.)                      // "wtrqe"

See Also: CSETREF() Introduction

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.