Hi thanks for reply. I'll explain in more detail why I am sorting as a list. For example.
V1 = [x,yx,xyz,xy^2, x^2yz,xz^2] is a list of variables. This has and associated list of coefficients
C1=[1+a,a^2-3,a^3-a^2,15,2+a,-12] Both these lists have 6 elements
V2= [x,yx,xyz, x^2yz,xz^2]
C2=[a,2,1-3a,a^2-5,7a,a^2] 5 elements in V2 & C2. V2 is missing "xy^2", i.e. the 4th element in V1
I have 19 lists of variables and coefficients. Max list length is 19 some lists only 16 or 17 elements. The coefficients lists form the rows of 19x 19 matrix. The determinant is used to get a univariate polynomial in "a".
The missing elements in the variable lists cause elements of the coefficient lists to be placed in wrong columns.
I see 2 possible sorting stratagies
a) add a 0 to C2 in 4th position increasing its length by 1.
b) sort C1,V1 based on the sequence of variables in V2 and placing the "xy^2" at the end of the list
New V1 = [x,yx,xyz, x^2yz,xz^2,xy^2] and C1=[1+a,a^2-3,a^3-a^2,2+a,-12,15]
I do not know how the impliment either of the approaches.
I posted this last night when trying to sort the problem. The above describes the core of the problem