Dear Forum,

is there a reason why the versions Sort and SortParallel exist with an optional Argument func which permits to define an own comparison function while for Sortex and SortingPerm such a version does not exist?

There is no fundamental reason for this (and in the next release such functionality will be available), the most likely reason is that it can be easily emulated, see below.

And if so, is there a simple way to obtain what

 SortingPerm(ConjugacyClasses, cmp)

would do (for a given function cmp) if there were such a version?

Yes. You can use `SortParallel' to build a permutation (in fact this is what `Sortex' does internally):

gap> l:=[6,2,9,4,5];
gap> pos:=[1..Length(l)]; # list of positions
gap> SortParallel(l,pos,function(a,b) return a>b;end); # reverse sorting function
gap> l;
[ 9, 6, 5, 4, 2 ]

Now `PermList(pos)' is the inverse of permutation that will do the same sort:

gap> l:=[6,2,9,4,5]; # old list again
gap> Permuted(l,PermList(pos)^-1);
[ 9, 6, 5, 4, 2 ]

All the best,

   Alexander Hulpke


_______________________________________________
Forum mailing list
[email protected]
http://mail.gap-system.org/mailman/listinfo/forum

Reply via email to