Mathematica 9 is now available

Sort

Usage

Sort[list] 以规范顺序对 list 中元素排序.
Sort[list, p] 使用排序函数plist 中元素排序.


Notes

• 例如: Sort[ b, c, a ]LongRightArrow .
Mathematica 所使用的规范顺序的详细描述参见A.3.9节.
Sort[list, p] 把函数 p 应用到 list 中的元素对上以确定它们是否是按顺序排列的. 缺省的函数 pOrderedQ[{#1, #2}]&.
• 例如: Sort[ 4, 1, 3 , Greater]LongRightArrow .
Sort 可被使用到带任意头(不单是 List)的表达式上.
• 参见 Mathematica 全书: 1.8.9节 和 2.2.10节.
• 同时参见: Order, OrderedQ, Orderless.
Further Examples

You can put a list of letters into canonical order.

In[1]:=  

Out[1]=

Both of these commands sort the list from largest to smallest.

In[2]:=  

Out[2]=

In[3]:=  

Out[3]=

This puts elements that do not depend on x before those that do.

In[4]:=  

Out[4]=

Here are two numbers.

In[5]:=  

In[6]:=  

In the canonical order x comes before y.

In[7]:=  

Out[7]=

However, x is greater than y in magnitude.

In[8]:=  

Out[8]=

Ordering numeric expressions according to magnitude by default would usually be too slow. This is why the following differ.

In[9]:=  

Out[9]=

In[10]:=  

Out[10]=

In[11]:=  



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.