# Singular          #### D.15.12.29 difformListSort

Procedure from library `difform.lib` (see difform_lib).

Return:
the sorted list L in ascending order, depending on the optional monomial ordering given

Remarks:
Classical insertion sort is used to sort the list

Note:
- the procedure uses difformIsBigger to compare list elements, therefore an optional ordering is defined via the pattern in difformIsBigger - the standard ordering is the ordering on the differential algebra - the procedure can also handle special lists of lists by using the optional input "Dlist" or "Llist":
- "Dlist" is used for lists with structure:
L is a list of differential forms
L is a list of polynomials of same size,
The list gets sorted by the elements in L. This is mainly used for the structure of derivations.
- "Llist" allows the structure: L[i] is a list with two entries: L[i] is a differential form
L[i] is a polynomial
The list gets sorted by the elements L[i]. This is used to sort coefficient lists.

Example:
 ```LIB "difform.lib"; ring R = 0,(x,y,z,t),dp; diffAlgebra(); ==> // The differential algebra Omega_R was constructed and the differential \ forms dx, dy, dz, dt are available. ///////////////////////// // Sortation of a list // ///////////////////////// list L = dx*x, x2 - y*t, 12, dt*dy*dx*dz; // Sort list with standard ordering difformListSort(L); ==> : ==> 12 ==> ==> : ==> x2-yt ==> ==> : ==> x*dx ==> ==> : ==> dx*dy*dz*dt ==> // Sort list with changed ordering difformListSort(L,"gen","ls","ringvar","wp",intvec(-1,1,1,1)); ==> : ==> dx*dy*dz*dt ==> ==> : ==> x*dx ==> ==> : ==> 12 ==> ==> : ==> x2-yt ==> ///////////////////////////////////////////// // Sortation of list with strcture "Dlist" // ///////////////////////////////////////////// list DL; DL = list(dx,x,t,dt); DL = list(y,t*z,4,x); // This list has the structure described by "Dlist" difformListSort(DL,"Dlist","ringvar","ls"); ==> : ==> : ==> x ==> ==> : ==> t ==> ==> : ==> dt ==> ==> : ==> dx ==> ==> : ==> : ==> zt ==> : ==> 4 ==> : ==> x ==> : ==> y ///////////////////////////////////////////// // Sortation of list with strcture "Llist" // ///////////////////////////////////////////// list LL; LL = list(dx,x); LL = list(t*dt,y); LL = list(x,2); // This list has the structure described by "Llist" difformListSort(LL,"Llist"); ==> : ==> : ==> x ==> ==> : ==> 2 ==> : ==> : ==> t*dt ==> ==> : ==> y ==> : ==> : ==> dx ==> ==> : ==> x kill Omega_R,dx,dy,dz,dt,L,DL,LL; ``` 