GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "typedef.h"1#include "datei.h"23static int smaller(char *s1,char *s2)4{56int i,7j;89/* the first criterion is the dimension */10sscanf(s1,"%d",&i);11sscanf(s2,"%d",&j);1213if (i<j){14return TRUE;15}16else if (i>j){17return FALSE;18}1920/* are these multiples of the same symbol ? */21i = strcspn(s1,",");22j = strcspn(s2,",");23if ( (i==j) && strncmp(s1,s2,i)==0){24if (strlen(s1)<strlen(s2)){25return TRUE;26}27else{28return FALSE;29}30}3132/* we are now in the position to distinguish it on one atomic symbol */33/* the symbol has to contain a '-' now */34s1 = strchr(s1,'-');35s2 = strchr(s2,'-');36s1++;37s2++;38sscanf(s1,"%d",&i);39sscanf(s2,"%d",&j);4041if (i>j){42return TRUE;43}44else if (i<j){45return FALSE;46}4748/* now one of them is of the form a-b', and the other one of a-b */49/* a-b' < a-b */50if (strchr(s1,'\'') == NULL){51return TRUE;52}5354return FALSE;55}5657void right_order(char *string)58{5960int i,61j,62ordered,63hom_no;6465char *irr_symbol[MAXDIM],66*tmp,67*tmp2,68*tmp3;6970for (i=0;i<MAXDIM;i++){71irr_symbol[i] = (char *) calloc(20 , sizeof(char));72}7374tmp = (char *) calloc(20 * MAXDIM, sizeof(char));7576/* get the irreducible symbols, ie. those seperated by `;' */77strcpy(tmp,string);78tmp3 = tmp2 = tmp;79hom_no = 0;80while (tmp3 != NULL){81tmp3 = strchr(tmp2,';');82if (tmp3 == NULL){83strcpy(irr_symbol[hom_no],tmp2);84}85else{86strncpy(irr_symbol[hom_no],tmp2,strlen(tmp2)-strlen(tmp3));87tmp2 = tmp3+1;88}89hom_no++;90}919293/* order the symbols */94ordered = FALSE;95while (!ordered){96ordered = TRUE;97for (i=0;i<hom_no-1;i++){98if (smaller(irr_symbol[i],irr_symbol[i+1])){99tmp2 = irr_symbol[i];100irr_symbol[i] = irr_symbol[i+1];101irr_symbol[i+1] = tmp2;102ordered = FALSE;103}104}105}106107/* reprint them into string */108sprintf(string,"%s",irr_symbol[0]);109for (i=1;i<hom_no;i++){110sprintf(tmp,"%s;%s",string,irr_symbol[i]);111sprintf(string,"%s",tmp);112}113114/* free */115for (i=0;i<MAXDIM;i++){116free(irr_symbol[i]);117}118free(tmp);119120return;121122}123124125