       Re: Ordering function weird?

• To: mathgroup at smc.vnet.net
• Subject: [mg82690] Re: [mg82645] Ordering function weird?
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Sun, 28 Oct 2007 04:08:27 -0500 (EST)
• References: <200710270959.FAA10950@smc.vnet.net>

```*This message was transferred with a trial version of CommuniGate(tm) Pro*

On 27 Oct 2007, at 18:59, Claus wrote:

> Hi,
> say I've got two sets of number, x and y, which I want to rank. See
> the
> example below. I totally expect and want the result of Ordering[x].
> But
> I neiter understand nor expect the result of Ordering[y]. Both Sort[x]
> and Sort[y] are ok.
> Can anybody explain to me Ordering[y]?
> Thanks,
> Claus
>
>
> In:= x = {1, 2, 3, 6, 10, 3, 4}
> y = {1, 2, 7, 8, 9, 1, 2}
>
> Out= {1, 2, 3, 6, 10, 3, 4}
>
> Out= {1, 2, 7, 8, 9, 1, 2}
>
> In:= Sort[x]
> Sort[y]
>
> Out= {1, 2, 3, 3, 4, 6, 10}
>
> Out= {1, 1, 2, 2, 7, 8, 9}
>
> In:= Ordering[x]
> Ordering[y]
>
> Out= {1, 2, 3, 6, 7, 4, 5}
>
> Out= {1, 6, 2, 7, 3, 4, 5}
>

Well, just look at the Help message for Ordering:

Ordering gives the positions in  list at which each successive
element of  Sort[list]
appears.

So now, your list is y = {1, 2, 7, 8, 9, 1, 2}. Your Sort[list] is
Sort[y]
{1, 1, 2, 2, 7, 8, 9}

So the first element of Sort[y] is 1 and it appears in positions 1
and 6 in your original list. The next successive element is 2 (the
second 1 is not counted) and it appears in positions 2 and 7, etc. So
Ordering[y[ should be
{1,6,2,7 ...} and indeed it is
Ordering[y]
{1, 6, 2, 7, 3, 4, 5}

Andrzej Kolowski

```

• Prev by Date: Re: Can't calculate numerical derivative of EllipticTheta
• Next by Date: Re: Ordering function weird?
• Previous by thread: Ordering function weird?
• Next by thread: Re: Ordering function weird?