/* $DOC$ $NAME$ CharSort() $CATEGORY$ CT3 string functions $ONELINER$ Sort sequences within a string. $SYNTAX$ CharSort( <[@]cString>, [], [], [], [], [], [] ) -> cSortedString $ARGUMENTS$ <[@]cString> is the string that should be processed [] specifies the length of the elements that should be sorted Default: 1 [] specifies how many characters within one element should be used for comparison Default: [] specifies the number of characters at the beginning of that should be ignored in the sort process Default: 0 [] specifies the offset of the comparison string within a element Default: 0 [] specifies how many characters in , starting from the position, should be sorted Default: Len(cString)-nIgnoreCharacters []) specifies whether the process should sort descending or not $RETURNS$ the string resulting from the sort process $DESCRIPTION$ The CharSort() function sorts the characters within a string . With the parameters and , you can determine that only the substring from position +1 to position + within should be sorted. The sorting algorithm is determined with the other parameters. specifies the length of one element, i.e. there are / elements that are sorted. Note that surplus characters are not sorted but stay at their position. To do the sorting, the function uses the Quicksort algorithm implemented in the C-lib qsort() function. This algorithm needs to know how to compare and order two elements. This is done by comparing the ASCII values of a substring within each element. This substring is determined by the parameters and and the order by . By setting the CSetRef() switch to .T., one can omit the return value of the function, but one must then pass by reference. $EXAMPLES$ ? CharSort( "qwert" ) // "eqrtw" ? CharSort( "qwert", 2 ) // "erqwt" ? CharSort( "b1a4a3a2a1", 2, 1 ) // "a2a1a3a4b1" ? CharSort( "XXXqwert", 1, 1, 3 ) // "XXXeqrtw" ? CharSort( "b1a4a3a2a1", 2, 1, 0, 1 ) // "a1b1a2a3a4" ? CharSort( "384172852", 1, 1, 0, 0, 4 ) // "134872852" ? CharSort( "qwert", .T. ) // "wtrqe" $STATUS$ Ready $COMPLIANCE$ CharSort() is compatible with CT3's CharSort(). $PLATFORMS$ All $FILES$ Library is hbct. $SEEALSO$ CSetRef() $END$ */