Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 5135

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>sort(List) -- sort a list</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_sort_lp__Matrix_rp.html">next</a> | <a href="_sort_lp..._cm_sp__Monomial__Order_sp_eq_gt_sp..._rp.html">previous</a> | <a href="_sort_lp__Matrix_rp.html">forward</a> | <a href="_sort_lp..._cm_sp__Monomial__Order_sp_eq_gt_sp..._rp.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<hr/>
<div><h1>sort(List) -- sort a list</h1>
<div class="single"><h2>Synopsis</h2>
<ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>sort v</tt></div>
</dd></dl>
</div>
</li>
<li><span>Function: <a href="_sort.html" title="sort a list or columns of a matrix">sort</a></span></li>
<li><div class="single">Inputs:<ul><li><span><tt>v</tt>, <span>a <a href="___List.html">list</a></span></span></li>
</ul>
</div>
</li>
<li><div class="single">Outputs:<ul><li><span><span>a <a href="___List.html">list</a></span>,  of the same length as <tt>v</tt> sorted in ascending order</span></li>
</ul>
</div>
</li>
<li><div class="single"><a href="_using_spfunctions_spwith_spoptional_spinputs.html">Optional inputs</a>:<ul><li><span><a href="_sort_lp..._cm_sp__Degree__Order_sp_eq_gt_sp..._rp.html">DegreeOrder => ...</a>,  -- specify Ascending, Descending, or null</span></li>
<li><span><a href="_sort_lp..._cm_sp__Monomial__Order_sp_eq_gt_sp..._rp.html">MonomialOrder => ...</a>,  -- specify Ascending or Descending monomial order</span></li>
</ul>
</div>
</li>
</ul>
</div>
<div class="single"><h2>Description</h2>
<div><p>The sort function uses <a href="__lt_eq.html" title="less than or equal">&lt;=</a> to compare elements of the list, which in turn calls upon the comparison operator <a href="__qu.html" title="comparison operator">?</a>, so, to determine how the elements are sorted, refer to its documentation.  Methods for new user defined types of objects can be installed for it, too, to obtain the desired sorting behavior.</p>
<table class="examples"><tr><td><pre>i1 : sort {c,e,a,f,b,f}

o1 = {a, b, c, e, f, f}

o1 : List</pre>
</td></tr>
<tr><td><pre>i2 : sort {4,2,6,3,8,2}

o2 = {2, 2, 3, 4, 6, 8}

o2 : List</pre>
</td></tr>
</table>
<p>Comparison of strings is implemented so that symbols come before alphanumeric characters, upper and lower case characters are sorted together, and strings of digits are sorted by size of the implied number.</p>
<table class="examples"><tr><td><pre>i3 : sort {"a11","a1","a2","A11","A1","A2","B2"}

o3 = {A1, a1, A2, a2, A11, a11, B2}

o3 : List</pre>
</td></tr>
</table>
<p>Visible lists (lists, sequences, and arrays) are compared lexicographically.</p>
<table class="examples"><tr><td><pre>i4 : sort {(1,1),(2,1),(3,1),(1,2),(3,2)}

o4 = {(1, 1), (1, 2), (2, 1), (3, 1), (3, 2)}

o4 : List</pre>
</td></tr>
</table>
<p>If the elements of the list are polynomials, then the monomial order is used to sort the elements according to their lead terms.</p>
<table class="examples"><tr><td><pre>i5 : R = ZZ[a..d,MonomialOrder=>Lex];</pre>
</td></tr>
<tr><td><pre>i6 : sort{a*d, b^100, c^3*d}

       3    100
o6 = {c d, b   , a*d}

o6 : List</pre>
</td></tr>
</table>
<p>The optional arguments are not used in this version of sort.</p>
</div>
</div>
<div class="single"><h2>Caveat</h2>
<div>If a list contains elements of different types, the sorting still occurs, but might not be particularly intuitive.</div>
</div>
<div class="single"><h2>See also</h2>
<ul><li><span><a href="_rsort.html" title="sort a list or matrix in reverse order">rsort</a> -- sort a list or matrix in reverse order</span></li>
<li><span><a href="__lt_eq.html" title="less than or equal">&lt;=</a> -- less than or equal</span></li>
<li><span><a href="__qu.html" title="comparison operator">?</a> -- comparison operator</span></li>
</ul>
</div>
</div>
</body>
</html>