Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4445

Re: What "Sort" option of :Values does?

From "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: What "Sort" option of :Values does?
Date 2011-08-17 09:53 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j2g336$1d8$1@smc.vnet.net> (permalink)
References <j2cv3a$hfg$1@smc.vnet.net>

Show all headers | View raw


On Tue, 16 Aug 2011 06:27:06 +0100, Alexey Popkov <lehin.p@gmail.com>  
wrote:

> All the ...Values functions have undocumented option Sort:
>
> In[1]:= Options /@ {OwnValues, DownValues, UpValues, SubValues,
>   DefaultValues, FormatValues, NValues}
>
> Out[1]= {{Sort -> True}, {Sort -> True}, {Sort -> True}, {Sort ->
>    True}, {Sort -> True}, {Sort -> True}, {Sort -> True}}
>
> What this option does?
>

Sort -> True (the default) sorts *Values into lexicographic order in the  
output of these functions, acting as if they were Orderless (which  
actually they are not). Sort -> False, on the other hand, keeps them in  
the same order that they appear internally, which is to say the order in  
which they will be applied (and usually also the order in which they were  
defined). A simple example:

In[1] :=
a[2] = 2;
a[1] = 1;

In[3] :=
DownValues[a]

Out[3] =
{HoldPattern[a[1]] :> 1, HoldPattern[a[2]] :> 2}

In[4] :=
DownValues[a, Sort -> False]

Out[4] =
{HoldPattern[a[2]] :> 2, HoldPattern[a[1]] :> 1}

In the case of OwnValues the meaning of this is not readily apparent at  
first glance. However, a symbol can actually have multiple OwnValues if  
Condition is used, and sorting becomes meaningful in such a case.

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

What "Sort" option of :Values does? "Alexey Popkov" <lehin.p@gmail.com> - 2011-08-16 05:27 +0000
  Re: What "Sort" option of :Values does? "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-08-17 09:54 +0000
  Re: What "Sort" option of :Values does? "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-08-17 09:53 +0000

csiph-web