       Re: Ordering function weird?

• To: mathgroup at smc.vnet.net
• Subject: [mg82687] Re: Ordering function weird?
• From: Szabolcs Horvát <szhorvat at gmail.com>
• Date: Sun, 28 Oct 2007 04:06:55 -0500 (EST)
• References: <ffv29v\$aph\$1@smc.vnet.net>

```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]?

What do you find "weird" about it?  It gives the result I expect:
y[[Ordering[y]]] is the same as Sort[y].

>
>
> 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}
>

--
Szabolcs

```

• Prev by Date: Why is NonCommutativeMultiply Protected?
• Next by Date: Re: Ordering function weird?
• Previous by thread: Re: Ordering function weird?
• Next by thread: Re: Ordering function weird?