easiest way to sort a list?

• To: mathgroup at smc.vnet.net
• Subject: [mg18308] easiest way to sort a list?
• From: peterw at cco.caltech.edu (Peter T. Wang)
• Date: Fri, 25 Jun 1999 22:24:15 -0400
• Organization: California Institute of Technology, Pasadena
• Sender: owner-wri-mathgroup at wolfram.com

```Hi everyone,

Here's my question:  Suppose you have a list of integers, not all distinct,
say
{1, 5, 3, 5, 10, 10, 1},

and you want to obtain the list

{1, 5, 3, 10}

which is the set of distinct elements but with the order preserved; i.e.,
the order in which the elements in the second list appear is the same as
the order in which it first occurs in the first list.  What is a simple
way to do this?  Evidently Union[] sorts the elements in canonical order,
which is not desirable.  My current solution is so messy that I suspect
there must be an easier way.

-peter

```

• Prev by Date: Re: O.D.E in Power Series
• Next by Date: Mathematica 4.0 improvements?
• Previous by thread: Elastodynamic tensor calculus on Mathematica
• Next by thread: Re: easiest way to sort a list?