Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*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 1999

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

Search the Archive

Re: Re: easiest way to sort a list?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18343] Re: [mg18324] Re: [mg18308] easiest way to sort a list?
  • From: "Tomas Garza" <tgarza at mail.internet.com.mx>
  • Date: Wed, 30 Jun 1999 14:13:17 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Andrew,
I'm afraid your proposed solution works in the particular example you used,
but it doesn't in general. Cf. the following:

In[1]:=
in = {2, 1}
Out[1]=
{2, 1}
In[2]:=
elements = Union[in]
Out[2]=
{1, 2}
In[3]:=
positions = Flatten[First[Position[in, #]] & /@ elements]
Out[3]=
{2, 1}
In[4]:=
in[[positions]]
Out[4]=
{1, 2}

The correct solution is {2,1}.

Tomas Garza
Mexico City



  • Prev by Date: MultiplicativeOrder[k,n] ?
  • Next by Date: Career Opportunity with Wolfram Research
  • Previous by thread: Re: Re: easiest way to sort a list?
  • Next by thread: Re: Re: easiest way to sort a list?