Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper Tools . Books 1-3 - <b>charsort()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 CHARSORT()
 Sorts sequences within a string
------------------------------------------------------------------------------
 Syntax

     CHARSORT(<cString>,[<nElementlength>],
        [<nComparisonlength>],[<nIgnore>],
        [<nElementPosition>],[<nSortlength>],
        [<lDescending>]) --> cString


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

 Arguments

     <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..

 Returns

     The sorted <cString> is returned.

 Description

     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.

 Notes

     .  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.

 Examples

     .  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

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson