TPP:=function(s,t) local i,str,u,j,v,up; for i in [1..Length(s)] do str:=""; u:=s; for up in [1,2] do for j in [1..Length(u[i])] do if j>1 then Add(str,','); fi; v:=String(u[i][j]); if Length(v)=1 then v:=Concatenation(" ",v); fi; Append(str,v); od; while up=1 and Length(str)<38 do Add(str,' '); od; u:=t; od; Print(str,"\n"); od; Print("=======\n"); end; RSKInsert:=function(t,a) local found, l, x,j,i; found:=false; j:=1; repeat if Length(t)t[j][l] then Add(t[j],a); found:=[j,l+1]; else i:=1; while i<=l do if a<=t[j][i] then #bump x:=t[j][i]; t[j][i]:=a; a:=x; j:=j+1; i:=l+1; fi; i:=i+1; od; fi; fi; until found<>false; return found; end; RSK:=function(pl) local s,t,i,a,pr; pr:=ValueOption("print")=true; s:=[]; t:=[]; for i in [1..Length(pl)] do a:=RSKInsert(s,pl[i]); if not IsBound(t[a[1]]) then t[a[1]]:=[]; fi; t[a[1]][a[2]]:=i; if pr then TPP(s,t); fi; od; return [s,t]; end;