Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Re: easiest way to sort a list?

  • To: mathgroup at
  • Subject: [mg18338] Re: [mg18320] Re: [mg18308] easiest way to sort a list?
  • From: "Tomas Garza" <tgarza at>
  • Date: Sun, 27 Jun 1999 15:11:24 -0400
  • Sender: owner-wri-mathgroup at

Both methods suggested by ARNOLDK [arnoldk at]work fine.
However, the use of ReplaceRepeated takes an inordinate amount of time. Any
idea why?

myNumbers = Table[Random[Integer, {1, 99}], {500}];

myNumbers //. {a___, b_, c___, b_, d___} -> {a, b, c, d}; // Timing

{46.52 Second, Null}

union2[l_] :=
  Fold[Flatten[If[! MemberQ[#1, #2], Append[#1, #2], #1]] &, {}, l]

union2[myNumbers]; // Timing

{0.06 Second, Null}

Tomas Garza
Mexico City

  • Prev by Date: Need just enough underbars
  • Next by Date: Re: Mathematica 2.2 on iMac?
  • Previous by thread: Re: RE: easiest way to sort a list?
  • Next by thread: Re: easiest way to sort a list?