| xHarbour Reference Documentation > Function Reference |  | 
|  |  |  | 
Sorts character (sequences) within a string.
CharSort( <cString>     , ;
         [<nSeqLen>]    , ;
         [<nCompareLen>], ;
         [<nSkipChars>] , ;
         [<nSkipSeq>]   , ;
         [<nSortLen>]   , ;
         [<lDescending>]  ) --> cResult
The function returns the sorted string or a null string ("") when an error occurs.
| See also: | CharRela() | 
| Category: | CT:String manipulation , Character functions | 
| Source: | ct\charsort.c | 
| LIB: | xhb.lib | 
| DLL: | xhbdll.dll | 
// The example demonstrates various sort results of CharSort()
   PROCEDURE Main
      LOCAL cStr := "4ef2ab1cd3gh"
      // sort single characters
      ? CharSort( cStr )             // result: 1234abcdefgh
      // sort character pairs
      ? CharSort( cStr, 2 )          // result: 1c4eabd3f2gh
      // sort character triplets (by digit)
      ? CharSort( cStr, 3 )          // result: 1cd2ab3gh4ef
      // sort character triplets (by alphabet)
      ? CharSort( cStr, 3, 2, 0, 1 ) // result: 2ab1cd4ef3gh
   RETURN
http://www.xHarbour.com