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


Groups > comp.soft-sys.math.mathematica > #7213 > unrolled thread

Re: reliably sort?

Started byLeonid Shifrin <lshifr@gmail.com>
First post2011-12-15 09:51 +0000
Last post2011-12-15 09:51 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: reliably sort? Leonid Shifrin <lshifr@gmail.com> - 2011-12-15 09:51 +0000

#7213 — Re: reliably sort?

FromLeonid Shifrin <lshifr@gmail.com>
Date2011-12-15 09:51 +0000
SubjectRe: reliably sort?
Message-ID<jccfvc$m8g$1@smc.vnet.net>
Union knows nothing about dates. It sorts according to a universal
canonical order, which is
described in the documentation for Sort. You real question then is whether
the Mathematica
canonical order will always coincide with the ordering by date, for your
lists of data. My
first impression is that this is so, but you may want to give it more
thought - there could be
some corner cases. Anyways, my main point is that you can answer this
question unambiguously
by consulting the Sort documentation.

Regards,
Leonid


On Wed, Dec 14, 2011 at 2:02 PM, Michael Stern <nycstern@gmail.com> wrote:

> I have noticed that if combine two lists of date/data objects using
> Union[], the result is sorted by date.
>
> For example
>
> In[]:= mins={{{2001, 1, 31}, 0.993268}, {{2002, 3, 31}, 1.01395},
> {{2003, 6, 30},
>   1.08647}, {{2005, 11, 30}, 1.14752}, {{2006, 9, 30},
>   1.18938}, {{2007, 2, 28}, 1.19658}, {{2008, 1, 31},
>   1.20432}, {{2011, 1, 31}, 1.37501}};
> In[]:= maxs={{{2000, 10, 31}, 1.01816}, {{2001, 12, 31}, 1.02714},
> {{2004, 2, 29},
>    1.12702}, {{2005, 3, 31}, 1.16986}, {{2010, 10, 31}, 1.39026}};
>
> In[]:= Union[maxs, mins]
>
> Out[]= {{{2000, 10, 31}, 1.01816}, {{2001, 1, 31},
>   0.993268}, {{2001, 12, 31}, 1.02714}, {{2002, 3, 31},
>   1.01395}, {{2003, 6, 30}, 1.08647}, {{2004, 2, 29},
>   1.12702}, {{2005, 3, 31}, 1.16986}, {{2005, 11, 30},
>   1.14752}, {{2006, 9, 30}, 1.18938}, {{2007, 2, 28},
>   1.19658}, {{2008, 1, 31}, 1.20432}, {{2010, 10, 31},
>   1.39026}, {{2011, 1, 31}, 1.37501}}
>
> Is this reliable behavior? Is there any case in which Union would /not/
> return results that have been properly sorted by date?
>
> Thank you,
>
> -Michael Stern
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web