Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Union in Mathematica versions 3 and 4

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23341] Re: Union in Mathematica versions 3 and 4
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Thu, 4 May 2000 02:59:10 -0400 (EDT)
  • References: <8ekv53$q8l@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Carl Woll" <carlw at u.washington.edu> wrote in message
news:8ekv53$q8l at smc.vnet.net...
...........
> The next thing to note is that Sort without the optional
> OrderFunction is much much faster than a sort using an optional
> OrderFunction. In my tests, this difference may be as much as 2 orders
> of magnitude. For example,
>
> In[1]:=
> data = Table[Random[], {100000}];
>
> In[5]:=
> s1 = Sort[data]; // Timing
> s2 = Sort[data, OrderedQ[{#1, #2}] &]; // Timing
> s1 === s2
>
> Out[5]=
> {0.609 Second, Null}
>
> Out[6]=
> {44.672 Second, Null}
>
> Out[7]=
> True

It is sometimes possible to avoid using OrderFunction:

data = Table[Random[], {10000}];
s2 = Sort[data, OrderedQ[{Sin[#1], Sin[#2]}] &]; // Timing // First
s3 = Sort[Transpose[{Sin[data], data}]][[All, 2]]; // Timing // First
s2 === s3

19.94 Second

0.44 Second

True
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565






  • Prev by Date: Re: avoid spurious vertical segment in step function plot
  • Next by Date: Symbols & Legend Fonts in MultipleListPlot...
  • Previous by thread: Union in Mathematica versions 3 and 4
  • Next by thread: RE: [Q] Equation solving?