three indices equations. (version 1)
peter.vlasschaert@gmail.com,23/10/2017
example

kill(all)$

p1:a(1,2,k)+a(1,3,k+1) = a(1,4,k);

solve(p1,a(1,3,k+1))[1];

We want to place  k+1 on the rhs ,k on  lhs
z1:  number of terms   'lhs'
z2:  number  of terms  'rhs'

z1:2;
z2:2;

p2:b[1]*a(1,2,k)+b[2]*a(1,3,k+1) = b[3]*a(1,4,k)+b[4]*a(2,2,k+1);

c(i,j,k):=subvar(c[i,j]^k,"");

p2a:ev(p2,a=c);

p3:part(p2a,1,1);
p4:part(p2a,1,2);
p5:part(p2a,2,1);
p6:part(p2a,2,2);

find : highest index i,j

p8:part(p2,1,1,1,1);
p9:part(p2,1,1,1,2);
p10:part(p2,1,1,1,3);
p11:part(p2,1,1,1,0);
p12:part(p2,1,1,2);
p13:part(p2,1,1,2,1);

p14:part(p2,1,2,2,1);
p15:part(p2,1,2,2,2);
p16:part(p2,1,2,2,3);
p17:part(p2,1,2,2,0);
p18:part(p2,1,2,1);
p19:part(p2,1,2,2,1);

i ,j    =  lower indexes
k      =  upper indexes
n1   = { lhs = 1,rhs = 2}
m1  = number of terms {lhs,rhs}
l1    = equation in question

lhs_index_i(m1,l1)  :=part(l1,1,m1,m1,1)$
lhs_index_j(m1,l1)  :=part(l1,1,m1,m1,2)$
lhs_index_k(m1,l1) :=part(l1,1,m1,m1,3)$
rhs_index_i(m1,l1)  :=part(l1,2,m1,1,1)$
rhs_index_j(m1,l1)  :=part(l1,2,m1,1,2)$
lhs_index_k(m1,l1) :=part(l1,2,m1,1,3)$
index_i(l1,n1,m1):=part(l1,n1,m1,if n1=1 then m1:m1 else  1,1)$
index_j(l1,n1,m1):=part(l1,n1,m1,if n1=1 then m1:m1 else  1,2)$
index_k(l1,n1,m1):=part(l1,n1,m1,if n1=1 then m1:m1 else  1,3)$
coef_b(l1,n1,m1)   := part(l1,n1,m1,2)$
index_b(l1,n1,m1) := part(l1,n1,m1,2,1)$

p20:part(p2,2,1,1,1);
p21:part(p2,2,1,1,2);
p22:part(p2,2,1,1,3);
p23:part(p2,2,1,1,0);
p24:part(p2,2,1,2);                  /*eq,rhs,m1,2    */
p25:part(p2,2,1,2,1);              /*eq,rhs,m1,2,1 */

lhs_index_j(2,p2) ;
index_j(p2,1,2);

index_b(p2,2,1) ;
coef_b(p2,2,1) ;

p26:part(p2,2,2,1,1);
p27:part(p2,2,2,1,2);
p28:part(p2,2,2,1,3);
p29:part(p2,2,1,1,0);
p30:part(p2,2,2,2);                  /*eq,rhs,m1,2    */
p31:part(p2,2,2,2,1);              /*eq,rhs,m1,2,1 */

sort : a list of elements

before :sort 'q1'

q1:[2,3,1,4];
q1[2];

after :sort'q1'

q2:sort(q1);
q2[2];

find : highest , index 'i' ?

method 1:

list_i1:makelist(index_i(p2,1,m1),m1,1,z1);
list_i2:makelist(index_i(p2,2,m1),m1,1,z2);
list_i:join(list_i1,list_i2);
max_i : sort(list_i)[z1+z2];

method 2:

for kk:1 thru 2 do
      if kk = 1 then  
    list1:makelist(index_i(p2,kk,m1),m1,1,z1)
         else
    list2:makelist(index_i(p2,kk,m1),m1,1,z2) ;
list_ii :join(list1,list2) ;      
max_ii:sort(list_ii)[z1+z2];

method 3: compound statement

                ( list_iii:[],
                 list_iii:endcons(makelist(index_i(p2,kk:1,m1),m1,1,z1),list_iii),     
                 list_iii:endcons(makelist(index_i(p2,kk:2,m1),m1,1,z2),list_iii))$
                  list_iii;
                  max_iii1:sort(list_iii[1])[z1] ;  
                  max_iii2:sort(list_iii[2])[z2] ;  
                  max_iii :sort([max_iii1,max_iii2])[2];

method 4:

              list_iiii: makelist(index_i(p2,1,m1),m1,1,z1)$
              list_hulp : []$
              list_hulp :list_iiii;                                            /* copy */
              list_iiii:endcons(makelist(index_i(p2,2,m1),m1,1,z2),list_iiii);
              list_iiii;
              max_iiii1: sort(list_iiii[3])[z2];                        /*first thrid element from the list */
              max_iiii2: sort(list_hulp)[z1];
              max_iiiii:sort([max_iiii1,max_iiii2])[2];

highest index 'i' =2 (example)

find : highest , index 'j' ?

list_j1:makelist(index_j(p2,1,m1),m1,1,z1);
list_j2:makelist(index_j(p2,2,m1),m1,1,z2);
list_j:join(list_j1,list_j2);
max_j: sort(list_j)[z1+z2];

highest index 'j' =4 (example)

place : k+1 indices to 'lhs'  =  k indices to 'rhs'

k+1   which => b[i], i=1..z1+z2

find k+1 from 'lhs' because n1=1

for m1:1 thru z1 do
    if index_k(p2,1,m1) = k+1  then  
       ( vv1: [m1,index_b(p2,1,m1) ],
        ww1:coef_b(p2,1,m1));       
      vv1;
      ww1;
     

find k+1 from 'rhs' because n1=2

for m1:1 thru z2 do
    if index_k(p2,2,m1) = k+1  then  
       ( vv2: [m1,index_b(p2,2,m1) ],
        ww2:coef_b(p2,2,m1) );
      vv2;
      ww2;

rhs_kplus1:part(p2,1) -part(p2,2,vv2[1])= part(p2,2)-part(p2,2,vv2[1]);

find k from 'lhs' because n1=1

for m1:1 thru z1 do
    if index_k(p2,1,m1) = k  then  
       ( vvk1: [m1,index_b(p2,1,m1) ],
        wwk1:coef_b(p2,1,m1) );
      vvk1;
     vvk1[1];
   

find k from 'rhs' because n1=2

for m1:1 thru z2 do
    if index_k(p2,2,m1) = k  then  
       ( vvk2: [m1,index_b(p2,2,m1) ],
        wwk2:coef_b(p2,2,m1) );
      vvk2;   

lhs_k : part(rhs_kplus1,1)-part(p2,1,vvk1[1])=part(rhs_kplus1,2)-part(p2,1,vvk1[1]);

result : k+1 along 'lhs',k along  'rhs'

p3b:ev(lhs_k,a=c);