StringTools
SortPermutation
return a permutation that sorts a list of strings
Calling Sequence
Parameters
Description
Examples
SortPermutation( los )
los
-
list(string); a list of strings
The SortPermutation( los ) command returns a permutation p that sorts the list los, that is, for which seqlospi,i=1..nopslos is equal to sortlos. The sorting order is lexicographic.
The permutation returned by SortPermutation is represented as a list of the positive integers from 1 to nopslos.
Note that an empty list, which is vacuously a permutation, is returned if the input list los is empty.
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.
withStringTools:
L≔b,c,a:
p≔SortPermutationL
p≔3,1,2
typep,permlist
true
seqLpi,i=1..3
a,b,c
sortL
SortPermutation
See Also
sort
string
Download Help Document