# sort(Matrix) -- sort the columns of a matrix

## Synopsis

• Function: sort
• Usage:
sort m
• Inputs:
• m, , between free modules
• Optional inputs:
• DegreeOrder => ..., default value null, specify Ascending, Descending, or null
• MonomialOrder => ..., default value Ascending, specify Ascending or Descending monomial order
• Outputs:
• , with the same shape as m whose columns are sorted in increasing order

## Description

The default order is to sort the columns in ascending degree first, and within each degree, first compare ring elements in the highest non-zero component, breaking ties by going to the next lower component. Zero is considered earlier in the order than other elements

 i1 : R = ZZ/32003[a..d,MonomialOrder=>Lex]; i2 : m = matrix{{a*d, b^2, b^100, b^50*d^50, c^2*d}} o2 = | ad b2 b100 b50d50 c2d | 1 5 o2 : Matrix R <--- R i3 : sort m o3 = | c2d b2 b50d50 b100 ad | 1 5 o3 : Matrix R <--- R

The two optional arguments can modify this default order. The value of DegreeOrder is considered first (Ascending, Descending, or null), and after that the monomial (or ring) order is used to break ties, either ascending or descending, depending on the value of MonomialOrder.

To sort the columns of m in descending monomial order:

 i4 : options sort o4 = OptionTable{DegreeOrder => null } MonomialOrder => Ascending o4 : OptionTable i5 : sort(m, DegreeOrder=>null, MonomialOrder=>Descending) o5 = | ad b100 b50d50 b2 c2d | 1 5 o5 : Matrix R <--- R