Previous Up Next

6.3.20  Sorting by a permutation

The sortperm command returns the permutation which sorts the given list in ascending order or the list sorted by the given permutation.

Examples

V:=[30,25,40,10,20]; P:=sortperm(V)
     

3,4,1,0,2
          
S:=["ab","cd","ad","bc","de"]; sortperm(S,P)
     

“bc”,“de”,“cd”,“ab”,“ad”
          

Previous Up Next