Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » lists and sequences » sort » sort(Matrix)
next | previous | forward | backward | up | index | toc

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

- Function: sort
- Usage:
    `sort m`
- Inputs:
  - m, a matrix, 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:
  - a matrix, 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

## See also

- sortColumns -- permutation giving sort order

### Menu

- sort(...,MonomialOrder=>...) -- specify Ascending or Descending monomial order
- sort(...,DegreeOrder=>...) -- specify Ascending, Descending, or null
- Ascending -- specify ascending order
- Descending -- specify descending order

## Ways to use this method:

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

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/functions/sort-doc.m2:56:0.