27.32 Sortex

Sortex( list )

Sortex sorts the list list and returns the permutation that must be applied to list to obtain the sorted list.

    gap> list1 := [ 5, 4, 6, 1, 7, 5 ];;
    gap> list2 := Copy( list1 );;
    gap> perm := Sortex( list1 );
    (1,3,5,6,4)
    gap> list1;
    [ 1, 4, 5, 5, 6, 7 ]
    gap> Permuted( list2, perm );
    [ 1, 4, 5, 5, 6, 7 ] 

Permuted (see Permuted) allows you to rearrange a list according to a given permutation.

Previous Up Top Next
Index

GAP 3.4.4
April 1997