Sort - Maple Help

StringTools

 Sort
 sort a string

 Calling Sequence Sort( s )

Parameters

 s - Maple string

Description

 • The Sort(s) command returns a string whose characters are those appearing in s in sorted order.
 • A linear time combinatorial sorting algorithm is used to sort the input string s. Because strings in Maple are immutable, the string s is not sorted in-place''; instead, a sorted copy of s is returned. For this reason, the space complexity of the algorithm is also O(n). However, the sorting algorithm employs only constant space overhead to sort the copied string.
 • Note that Sort does not sort lists or sets of strings, but sorts the characters (bytes) in the string itself. To sort a list of strings, use the built-in procedure sort.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $s≔\mathrm{Random}\left(10,'\mathrm{lower}'\right)$
 ${s}{≔}{"yhcmxxkyzm"}$ (1)
 > $t≔\mathrm{Sort}\left(s\right)$
 ${t}{≔}{"chkmmxxyyz"}$ (2)
 > $\mathrm{IsSorted}\left(t\right)$
 ${\mathrm{true}}$ (3)